(The context for this question is the same as the previous q…
(The context for this question is the same as the previous question) You are a developer implementing a custom program for a new robotics platform that allows a robot to perform two operations, A and B, simultaneously. The operations are executed independently by two threads on a cache coherent shared memory multicore CPU. During execution, the two operations access a shared resource that requires mutual exclusion. Your teammate implements the lock as follows: Lock(L) { back: while (L == locked); // spin on read if (test-and-set(L) == locked) go back; } Unlock(L) { L = unlocked; } Suggest how this situation can be averted.
Read Details