Question: Consider the following function that implements acquiring a lock ( assume that TestAndSet is an atomic instruction ) . Observe that this code's approach to
Consider the following function that implements acquiring a lock assume that TestAndSet is an atomic instruction Observe that this code's approach to waiting for a held lock to be released is to "spin". void lock lock t lockwhile TestAndSet &lockflag, ; spinwait do nothingi Briefly explain why the way this code spins is inefficient and wastes resources.ii Briefly explain how this code could be modified to avoid that inefficiency. Hint: we studied two different strategies; either is an acceptable answer here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
