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 ______. GATE tbb-mockgate-3 numerical-answers operating-system process-synchronization semaphore + – Bikram asked Feb 9, 2017 • retagged Sep 16, 2020 by ajaysoni1924 Bikram 433 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply jatin khachane 1 commented Jan 1, 2019 i edited by jatin khachane 1 Jan 1, 2019 reply Follow Share @Utkarsh Joshi Maximum value of S asked at the end of execution of program or in between ?? 1 votes 1 votes Utkarsh Joshi commented Jan 1, 2019 reply Follow Share Maximum value at any time be it at the end or in between 1 votes 1 votes Please log in or register to add a comment.
Best answer 3 votes 3 votes 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. Harsh181996 answered Mar 13, 2017 • selected Mar 13, 2017 by Bikram Harsh181996 comment Share Follow See 1 comment See all 1 1 comment reply kshitij86 commented Sep 22, 2021 reply Follow Share Should it also be mentioned where this value is maximum? 0 votes 0 votes Please log in or register to add a comment.