Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started