cs431 icon indicating copy to clipboard operation
cs431 copied to clipboard

[Question] Why there is no CachePadded in TicketLock?

Open dubuduru opened this issue 2 years ago • 2 comments

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.

dubuduru avatar Oct 16 '22 07:10 dubuduru

I think all the waiting threads are looking the same curr, it is true sharing.

2JS avatar Oct 16 '22 12:10 2JS

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.

dubuduru avatar Oct 16 '22 16:10 dubuduru