in Operating System
971 views
1 vote
1 vote
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 ?
in Operating System
971 views

1 comment

No Deadlock no starvation here.

I am thinking about giving equal chances to both processes. Then only no starvation is possible.
0
0

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.

4 Comments

what is the correct definition of starvation?
0
0
There isn't any infinite loop...

How can P1 execute again and again?
0
0
starvation means if any process want to execute  but any other process should stop it then starvation occure

in this  if  other process want to excute then it hold the value of semaphore  SX  and then execute
0
0
edited by
Starvation is the problem that occurs when (high priority) processes keep executing and (low priority ) processes get blocked for indefinite time.

Question is asking if it could lead to starvation? yes because if process P1 wants to continue it's execution again and again, it can because it has all the semaphore.
0
0

Related questions