Question: Reference Figure 1 below which presents the code snippets for two processes, P1 and P2, which will update a shared array called Wages. (a) Assume

 Reference Figure 1 below which presents the code snippets for two

Reference Figure 1 below which presents the code snippets for two processes, P1 and P2, which will update a shared array called Wages. (a) Assume that the two processes are given fixed time quantum on the CPU. Let P1 execute first and let it be preempted when j=20. List the variables which are changed by P1 and the values after each change. [2 marks] (b) Now let P2 run. Determine whether P2 gets to the code where the array is manipulated in the for loop. Clearly explain how you arrived at your answer. [2 marks] (c) A student Mark, decides to interchange the Tall and Short functions in the update 0 code of the two processes. If no further changes are made to P2 and P1, determine whether mutual exclusion is preserved. [3 marks] (d) Suppose Adam modifies the algorithm by including two consecutive lines of "Short(\&S);" instead of just one. If the variable value is initialized to 1, explain what happens when P1 executes. [3 marks] \begin{tabular}{|c|c|} \hline & \begin{tabular}{l} struct Semaphore \{ \\ int value; \\ struct process *list \\ \} \\ Tall (semaphore *S)\{ \\ S value ++; \\ if (S value

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!