in GATE retagged by
425 views
2 votes
2 votes

The following five concurrent processes operate on counting semaphore variable $\left ( S \right )$, which is initialized to $0$.

  • P1 : wait$\left ( s \right )$ ;     $cs$ ;     signal$\left ( s \right )$ ;
  • P2 : wait$\left ( s \right )$ ;     $cs$ ;     signal $\left ( s \right )$ ;
  • P3 : wait$\left ( s \right )$ ;     $cs$ ;     signal $\left ( s \right )$ ;
  • P4 : signal$\left ( s \right )$ ;  $cs$ ;     wait $\left ( s \right )$ ;
  • P5 : signal$\left ( s \right )$ ;  $cs$ ;     wait $\left ( s \right )$;


The maximum possible value of $S$ is ______.

in GATE retagged by
by
425 views

2 Comments

edited by

@Utkarsh Joshi

Maximum value of S asked at the end of execution of program or in between ??

1
1
Maximum value at any time be it at the end or in between
1
1

1 Answer

3 votes
3 votes
Best answer

The maximum possible value S is 2 (when P4 and P5 enter the critical section) ,

the rest processes decrement S before entering CS  and later increments it after completion of CS. 

Thus the overall value never goes beyond 2.

selected by

1 comment

Should it also be mentioned where this value is maximum?
0
0
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

64.3k questions

77.9k answers

244k comments

80.0k users