919 views
2 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 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.
Position:
Show:

Related questions

2 2 votes
1 1 answer
117
117 views
GO Classes asked Aug 26
117 views
Consider an integer semaphore $\texttt{S}$.Method $\textbf{1}$wait(S): disable interrupts while S <= 0: do nothing S = S - 1 enable interrupts signal(S): disable interrup...
2 2 votes
1 1 answer
148
148 views
GO Classes asked Aug 3
148 views
A bounded buffer has capacity $6$ and is initially empty.The semaphore values are initially:$\texttt{empty} = 6$$\texttt{full} = 0$$\texttt{mutex} = 1$During execution:$9...
3 3 votes
2 2 answers
132
132 views
GO Classes asked Jul 29
132 views
A bounded buffer has capacity $5$ and is initially empty.During an execution:$8$ producer insertions complete. $5$ consumer removals complete.Assume no insertion or remov...
1 1 vote
1 1 answer
97
97 views
GO Classes asked Jul 29
97 views
A producer-consumer system uses a buffer containing $N$ slots.The semaphores are:$\texttt{empty}$, representing empty slots $\texttt{full}$, representing filled slots $\t...