Assume that a system has multiple processing cores For each

Assume that a system has multiple processing cores. For each of the following scenarios, describe which is a better locking mechanism — a spinlock or a mutex lock where waiting processes sleep while waiting for the lock to become available:

a) The lock is to be held for a short duration.

b) The lock is to be held for a long duration.

c) The thread may be put to sleep while holding the lock.

Solution

The lock is to be held for a short duration: It makes more sense to use a spinlock as it may in fact be faster than using a mutex lock which requires suspending, awakening and the waiting process.


The lock is to be held for a long duration: A mutex lock is required as this allows the other processing core to schedule another process while the locked process waits.

A thread may be put to sleep while holding the lock: A mutex lock is required as you do not want the waiting process to be spinning while waiting for the other process to wake up.

Assume that a system has multiple processing cores. For each of the following scenarios, describe which is a better locking mechanism — a spinlock or a mutex lo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site