Jan. 31, 2018
7:39 p.m.
On Thu, 01 Feb 2018 00:15:03 +0530, Rohan Puri said:
See basic difference between mutex and spinlock is, the former puts the thread waiting on the lock to sleep and later does a busy wait.
Since the nth bit is set every X ms, I think sleeping and waking up would turn out to be costly operations/overhead so no mutex. Spinlock would be good enough here.
Depends on the value of X and the amount of contention. It's quite possible to lock up an entire CPU or even more for a considerable amount of ms out of every X using a spinlock.