Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  The following program consists of 3 concurren... Start Learning for Free
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.
How many times will process P0 print ‘0’? 
  • a)
    At least twice
  • b)
    Exactly twice
  • c)
    Exactly thrice
  • d)
    Exactly once
Correct answer is option 'A'. Can you explain this answer?
Most Upvoted Answer
The following program consists of 3 concurrent processes and 3 binary ...
Concept:
Binary semaphore which can take only two values 0 and 1 and ensure mutual exclusion.
A process is entered into the critical section only when the value of semaphore(s) = 1
Otherwise, it will wait until semaphore(s) >0
The semaphores are initialized as S0=1, S1=0, S2=0.
Because S0 =1 then P0 enter into the critical section and other processes will wait until either S1=1 or S2 =1
The minimum number of times 0 printed:
  • S0 =1 then P0 enter into the critical section
  • print '0'
  • then release S1 and S2 means S1 =1 and s2 =1
  • now either P1 or P2 can enter into the critical section
  • if P1 enter into the critical section
  • release S0
  • then P2 enter into the critical section
  • release S0
  • P1 enter into the critical section
  • print '0'
The minimum number of time 0 printed is twice when executing in this order (p0 -> p1 -> p2 -> p0)
The Maximum number of times 0 printed:
  • S0 =1 then P0 enter into the critical section
  • print '0'
  • Then release S1 and S2 means S1 =1 and s2 =1
  • Now either P1 or P2 can enter into the critical section
  • If P1 enter into the critical section
  • Release S0 means S0 =1
  • S0 =1 then P0 enter into the critical section
  • print '0'
  • Then P2 enter into the critical section
  • Release S0 means S0 =1
  • S0 =1 then P0 enter into the critical section
  • print '0'
Maximum no. of time 0 printed is thrice when execute in this order (p0 -> p1 -> p0 -> p2 -> p0)
So, At least twice will process P0 print ‘0’
Free Test
Community Answer
The following program consists of 3 concurrent processes and 3 binary ...
Concept:
Binary semaphore which can take only two values 0 and 1 and ensure mutual exclusion.
A process is entered into the critical section only when the value of semaphore(s) = 1
Otherwise, it will wait until semaphore(s) >0
The semaphores are initialized as S0=1, S1=0, S2=0.
Because S0 =1 then P0 enter into the critical section and other processes will wait until either S1=1 or S2 =1
The minimum number of times 0 printed:
  • S0 =1 then P0 enter into the critical section
  • print '0'
  • then release S1 and S2 means S1 =1 and s2 =1
  • now either P1 or P2 can enter into the critical section
  • if P1 enter into the critical section
  • release S0
  • then P2 enter into the critical section
  • release S0
  • P1 enter into the critical section
  • print '0'
The minimum number of time 0 printed is twice when executing in this order (p0 -> p1 -> p2 -> p0)
The Maximum number of times 0 printed:
  • S0 =1 then P0 enter into the critical section
  • print '0'
  • Then release S1 and S2 means S1 =1 and s2 =1
  • Now either P1 or P2 can enter into the critical section
  • If P1 enter into the critical section
  • Release S0 means S0 =1
  • S0 =1 then P0 enter into the critical section
  • print '0'
  • Then P2 enter into the critical section
  • Release S0 means S0 =1
  • S0 =1 then P0 enter into the critical section
  • print '0'
Maximum no. of time 0 printed is thrice when execute in this order (p0 -> p1 -> p0 -> p2 -> p0)
So, At least twice will process P0 print ‘0’
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer?
Question Description
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer?.
Solutions for The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer?, a detailed solution for The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer? has been provided alongside types of The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.How many times will process P0 print ‘0’?a)At least twiceb)Exactly twicec)Exactly thriced)Exactly onceCorrect answer is option 'A'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev