Question: 9. Hardware solutions to the critical section problem use read-modify-write instructions: these instructions are indivisible because the CPU gets to hold onto the memory bus

 9. Hardware solutions to the critical section problem use read-modify-write instructions:

9. Hardware solutions to the critical section problem use read-modify-write instructions: these instructions are indivisible because the CPU gets to hold onto the memory bus for two cycles, to both read and then update the shared memory location. As an ex- ample, hereis codeforimplementingmutual exclusion usingaSwap()machine-code instruction; that instruction has the opcode EXCH in the Pentium instruction set. Each process Piexecutes the same code to access its critical section, where key is a boolean localvariable and lockis a shared memorylocation among processes Pithat contains a boolean value, initially set to false. Process Pi: do { key = true; while (key == true) Swap(& lock, & key); ... Critical section of Pi... lock = false } while(true); Describe what happens if three processes try to enter their critical section at about the same time. How does the given code ensure that only one process gets entry

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!