Question: Consider the following code implementing a lock solution for two threads T1 and T2. int locked[2]; int turn =0; function enter_CS (id: integer) I repeat
Consider the following code implementing a lock solution for two threads T1 and T2. int locked[2]; int turn =0; function enter_CS (id: integer) I repeat U. locked[d] = true; V. while (tum I= id) do X. \& while (locked[t-id]) do; I/ do nothing Y. turn = id: ) Z. ecritical section of P> locked[id] = false, cremainder code for P> until false; 1 main 0 ( locked[0] = false; locked[1] = false; create thread to execute enter CS(0) : create thread to execute enter_CS(1); ) What type of concurrent programming problem will the above code have? Select the most specific one if multiple cases apply. Give the statement labol in your answor. A. Does not guarantee mutual exclusion. B. Will cause deadlock. C. A process may not be able to enter the critical section in a bounded time. D. Has the mutual courtesy problem (after you, atter you). E. Will force the processes to enter the critical section by taking turns
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
