4 ms·
So instead of locking one mutex to access a resource, you're locking N, so you're N times more likely to have mutex contention. Better let N=1.
by mayoff 15y ago
So instead of locking one mutex to access a resource, you're locking N, so you're N times more likely to have mutex contention. Better let N=1.
- sp332 15y agoI think you would boolean-OR the locks, so if any of the corresponding mutexes are unlocked, the resource is unlocked.
- DanWaterworth 15y agoThat wouldn't work because then you could lock the same resource twice.
- DanWaterworth 15y agoN can't be 1 because you can't fit the entire set of locks into memory, that's stated in the problem specification. The alternatives have a much higher locking overhead/contention rate than this approach.
- mayoff 15y agoOf course you can set N to 1. That's not the same as making the hash table size equal to the number of resources.
- DanWaterworth 15y agoOk, I see what you mean.