cs431
cs431 copied to clipboard
[Question] Why there is no CachePadded in TicketLock?
In ticketlock.rs, we define ticketlock struct as below:
pub struct TicketLock {
curr: AtomicUsize,
next: AtomicUsize,
}
But why curr and next not cachepadded? As they are modified by store() or fetch_add(), I think it would produce false sharing.
I think all the waiting threads are looking the same curr
, it is true sharing.
Thanks for comment. I was thinking about what would happen if multiple ticket locks exist and their curr and next uses same cache lines.. I think such situation will make false sharing happen.