-
The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
The number of district values that can possibly take after the ececution is ...............
-
- 0
- 1
- 3
- 5
Correct Option: C
If we execute P2 process after P1 process, then we get B = 3
If we execute P1 process after P2 process, then we get B = 4
If we did preemption between P1 and P2 processes, then we get B = 2 (Preemption have done from P1 to P2) or B = 3 (Preemption have done from P2 to P1). So, among 2 and 3 values, only one value will be saved in B. So, total no. of different values that B can possibly take after the execution is 3.