1,044 views
1 votes
1 votes
Given Processes P1: Wait(Sx); Wait(Sy); Do something;Signal(Sx); Signal(Sy); and Process P2: Wait(Sx); Wait(Sy); Do something;Signal(Sy); Signal(Sx); . Will it ever lead to starvation ?

2 Answers

2 votes
2 votes

No any deadlock and no any starvation because every process in P1  and P2 get wakeup (remain in continue states) ..after every wait () there is respective signal () operation in each Programm (P1 and P2 )  

0 votes
0 votes

P1:

Wait(Sx); Wait(Sy);

Do something;

Signal(Sx); Signal(Sy);

P2:

Wait(Sx); Wait(Sy);

Do something;

Signal(Sy); Signal(Sx); .

Assuming initial value of semaphore: sx =1 and sy = 1, otherwise no process will execute.

Starvation is possible in both the process. Because if one process starts it can continue to execute again and again.

Related questions

780
views
1 answers
1 votes
VS asked Jan 8, 2018
780 views
I am confused with what exactly Starvation mean ?AFAIK Considering Process Scheduling eg SRTF and SJF , Starvation can be considered when some process is ... Multiprocessor i.e. when we have multiple processing cores or CPUs available?
2.7k
views
3 answers
5 votes
learncp asked Dec 19, 2015
2,709 views
these are the codes for down and up operations in a binary semaphore. The down operation's code seems to be correct, but I am having some doubt in the ... to sleep again.. Am I missing something, or is the above implementation incorrect ?
355
views
0 answers
0 votes
admin asked Oct 30, 2019
355 views
Repeat the previous problem, but now avoid starvation. When a baboon that wants to cross to the east arrives at the rope and finds baboons crossing to the west ... are allowed to start until at least one baboon has crossed the other way.