340 views
2 votes
2 votes

Consider this implementation of semaphores b/w these $2$ processes :
PROCESS-1 :

V(s)

CS

P(S)

PROCESS-2:

P(s)

CS

V(S)

Assume that semaphore "s" is intialized to $0$ at initial stage .
Comment on these statments :

  • Process -$1$ can starve$.$
  • Process=$2$ can starve$.$

1 Answer

2 votes
2 votes
both processes can starve.

initially S=0, process P1 can only start the execution.

Process P1 can execute again and again without giving a chance to process P2. So P2 can starve.

Process P1 starts the execution, P1 preempts, P2 starts its execution, now P2 can keep on running without giving a chance to P1, hence P1 can also starve.

Related questions

0 votes
0 votes
1 answer
2
Mrityudoot asked Jan 27
225 views
Can a counting semaphore acquire a negative value?S = 2;15 P operations done, should the semaphore be 0 or -13