Question: 7 . The following shows two processes sharing a common variable ( X ) . Before the two processes are executed, X is

7. The following shows two processes sharing a common variable \( X \).
Before the two processes are executed, X is 5, and the statements described for each process are executed sequentially, and there is no assumption about the execution order of processes \( A \) and \( B \).[3 points]
(1) When the two processes are completed, write down the execution order of the processes (the execution order of \(\mathrm{A}1,\mathrm{~A}2,\mathrm{~B}1,\mathrm{~B}2\)) and all possible values that the variable X can have.
(2) If the following binary semaphore variable S is used, and before two processes are executed, S is 1 and X is 5, write down all the execution orders of the processes and the possible values that the variable \( X \) can have when the two processes are finished executing.
\[
\text {-}10\text {-}
\]
(3) If a binary semaphore variable \( T \) is used as follows, and before two processes are executed, \( T \) is 0 and \( X \) is 5, write down all the execution order of the processes and the possible values that the variable X can have.
```
//Process 0
int Y;
A1:Y = X*2;
A2:X = Y
A3:SemSignal(T);
```
```
//Process 1
int Z;
B1:SemWait(T);
B2:Z = X+1;
B3:X = Z;
```
7 . The following shows two processes sharing a

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 Programming Questions!