in Operating System edited by
1,550 views
1 vote
1 vote

Consider the following ‘C’ code

Assume P1 and P2 are two concurrent processes and sharing the global variables x, y and z. Assignments
and tests are atomic. Consider the following statements :
S1 : P1 and P2 terminates                           S2 : P1 terminates but P2 does not
S3 : P2 terminates but P1 does not            S4 : Neither P1 nor P2 terminates
 

my answer S1 and S4 but solution is different

in Operating System edited by
1.6k views

13 Comments

answer s1,s2,s4??
1
1
please explain
0
0
s2 is P1 will terminate when x>y but P2 will not because they are still not equal
0
0
x will never be greater than y
0
0
it will be when multiple p1's are run
0
0
I think you have a wrong notion of concurrency
Multiple processes can run together but not multiple instances of same process
0
0

https://en.wikipedia.org/wiki/Readers%E2%80%93writers_problem#First_readers-writers_problem   ---reader writer problem is example of concurrency have a look what it says about multiple instance

0
0
There are multiple readers and multiple writers hence multiple processes not multiple instances of the same process

I dont I'm able to explain this properly
you should ask some more experienced member they will probably be able to help
0
0
That is called multiple instances of the same process refers to the same process run with different instance like pid ; in multiple readers you don't write a different code for each process rather you run with different instances
0
0
By the way what is the ans given?
0
0
No answer in solution they have provided a solution for different problem :P
0
0
and you are approaching this wrong diffrent pid means different process id no relation with how any time you write code
0
0

2 Answers

2 votes
2 votes

These are 4 possibilities  


 


Hope it will help

by
0 votes
0 votes
answer could be S1,S2 and S4...

S3 not possible because if P2 terminate P1 has to terminate..

Related questions