Question: 1. Why is the following not ideal? /* implementation of a lock */ void lock () { DisableInterrupts (); } void unlock (0 {

1. Why is the following not ideal? /* implementation of a lock

1. Why is the following not ideal? /* implementation of a lock */ void lock () { DisableInterrupts (); } void unlock (0 { EnableInterrupts (); } /* a process that accesses some shared data */ Process { lock_t mutex; lock (&mutex); /* begin accessing shared data */ .. /* end accessing shared data */ unlock (&mutex); } 2. Why is the following not ideal? boolean test_and_set (boolean *target) boolean rv = *target; *target = TRUE; %3D return rv: } do { while (test_and_set (&lock)) ; /* do nothing */ /* critical section */ lock = false; /* remainder section */ } while (true);

Step by Step Solution

3.40 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Any solution to the critical section problem must satisfy three requirements mutual exclusion progre... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!