Is the following pseudocode correct or incorrect? If it is correct, explain how it correctly enforces mutual exclusion. If it is incorrect, explain why. while (!exit) { /* LENGTHY EVENT PROCESSING CODE GOES HERE */ int currEvents = totalEvents; enterMutualExclusion(); // Assume this works { totalEvents = currEvents + 1; } exitMutualExclusion(); // Assume this works}
Blog
Do processes have a “dead” state? Fully explain why or why n…
Do processes have a “dead” state? Fully explain why or why not. Do threads have a “dead” state? Fully explain why or why not.
Do you think the hybrid model of threading has all of the ad…
Do you think the hybrid model of threading has all of the advantages of both kernel and user, or are there disadvantages to the hybrid model that don’t apply to the other two? Fully explain your answer.
Name and explain two pieces of information tracked in a PCB…
Name and explain two pieces of information tracked in a PCB (process control block).
Below is the pseudocode of the first two versions of Dekker’…
Below is the pseudocode of the first two versions of Dekker’s algorithm. Explain the problem with the first that is corrected by the second and how the second corrects this problem. Note: The code of the threads (after the first global lines) will be written TWICE for each version. The first time, the code of the two threads are side-by-side to make it easier to compare them. But in case this does not show up properly on your screen, the code will be written again with T2’s code written AFTER T1’s. VERSION 1:int threadNumber = 1;startThreads();*** SIDE-BY-SIDE ***// T1: // T2:while (!done) { while (!done) { // non-critical code goes here // non-critical code goes here while (threadNumber == 2) ; // spin while (threadNumber == 1) ; // spin // this line marks entering mutual exclusion // this line marks entering mutual exclusion // critical section code is here // critical section code is here threadNumber = 2; // exiting mutual exclusion threadNumber = 1; // exiting mutual exclusion // more non-critical code goes here // more non-critical code goes here} }*** TOP AND BOTTOM ***// T1:while (!done) { // non-critical code goes here while (threadNumber == 2) ; // spin // this line marks entering mutual exclusion // critical section code is here threadNumber = 2; // exiting mutual exclusion // more non-critical code goes here} // T2:while (!done) { // non-critical code goes here while (threadNumber == 1) ; // spin // this line marks entering mutual exclusion // critical section code is here threadNumber = 1; // exiting mutual exclusion // more non-critical code goes here}VERSION 2:boolean t1Inside = false;boolean t2Inside = false;startThreads();*** SIDE-BY-SIDE ***// T1: // T2:while (!done) { while (!done) { while (t2Inside) ; // spin while (t1Inside) ; // spin t1Inside = true; // this line marks t2Inside = true; // this line marks // entering mutual exclusion // entering mutual exclusion // critical section code is here // critical section code is here t1Inside = false; // exiting mutual exclusion t2Inside = false; // exiting mutual exclusion // more non-critical code goes here // more non-critical code goes here} }*** TOP AND BOTTOM ***// T1:while (!done) { while (t2Inside) ; // spin t1Inside = true; // this line marks // entering mutual exclusion // critical section code is here t1Inside = false; // exiting mutual exclusion // more non-critical code goes here}// T2:while (!done) { while (t1Inside) ; // spin t2Inside = true; // this line marks // entering mutual exclusion // critical section code is here t2Inside = false; // exiting mutual exclusion // more non-critical code goes here} }
Is it possible for a process to transition directly from the…
Is it possible for a process to transition directly from the suspended-ready state to the suspended-blocked state? Explain why or why not.
What is a “real-time” system? Give one example of a real-tim…
What is a “real-time” system? Give one example of a real-time system that is NOT mission-critical or business critical and explain why this example is real-time.
Explain the concept of a load balancing.
Explain the concept of a load balancing.
What is the role of the Frontside Bus (FSB) in a computer ex…
What is the role of the Frontside Bus (FSB) in a computer executing instructions?
Why is the functionality of a PCB a good choice for OS funct…
Why is the functionality of a PCB a good choice for OS functionality to build into hardware? Note: PCB here refers to a Process Control Block, do NOT confuse this with a printed circuit board.