🙃Hey there,
Process A:
Process B:
Semaphores initilization:
If we consider the order of execution:
Α1->Α2->Β1->Α3->Β2 meaning A1 starts first and finishes then follow B1 with the same pattern etc.
Then the code is valid and this order of execution can be achieved, at least from my knowledge.
But, What if we have this order of execution?
Α1->Α2->Β1->Β2->Α3
In my opinion and the way I solve it, is that it is not possible at all because B2 will be paused and won't be able to finish (cause S2 will be -1).
Am I correct ? or I am missing crucial information on semaphores inner workings?
Thanks in advance.✌
Process A:
Code
down(s1);
up(s2);Process B:
Code
down(s2);
down(s2);
up(s1);
up(s2);Semaphores initilization:
Code
s1=2 , s2=0If we consider the order of execution:
Α1->Α2->Β1->Α3->Β2 meaning A1 starts first and finishes then follow B1 with the same pattern etc.
Then the code is valid and this order of execution can be achieved, at least from my knowledge.
But, What if we have this order of execution?
Α1->Α2->Β1->Β2->Α3
In my opinion and the way I solve it, is that it is not possible at all because B2 will be paused and won't be able to finish (cause S2 will be -1).
Am I correct ? or I am missing crucial information on semaphores inner workings?
Thanks in advance.✌

