...
Question 2670 – KVS 22-12-2018 Part-A
October 29, 2023
UGC NET CS 2016 Aug- paper-2
October 29, 2023
Question 2670 – KVS 22-12-2018 Part-A
October 29, 2023
UGC NET CS 2016 Aug- paper-2
October 29, 2023

Question 8174 – Operating-Systems

The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.

P1() 
{ 
   C = B – 1; 
   B = 2*C;  
}

P2()
{
   D = 2 * B;
   B = D - 1; 
}

The number of distinct values that B can possibly take after the execution is

Correct Answer: A

Question 40 Explanation: 
If we execute P2 process after P1 process, then B = 3
If we execute P1 process after P2 process, then B = 4
If we did preemption between P1 & P2 processes, then B = 2 (Preemption have done from P1 to P2) or B = 3 (Preemption have done from P2 to P1). So, among 2 & 3 values, only one value will be saved in B. So, total no. of distinct values that B can possibly take after the execution is 3.
A
3
B
4
C
5
D
6
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!