Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  The P and V operations on counting semaphores... Start Learning for Free
The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:
P(s) : s = s - 1;
   if (s < 0) then wait;
V(s) : s = s + 1;
    if (s <= 0) then wakeup a process waiting on s;
Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:
P(s) : Pb(Xb);
    s = s - 1;
   if (s < 0) {
  Vb(Xb) ;
  Pb(Yb) ;
}
else Vb(Xb);

V(s) : Pb(Xb) ;
    s = s + 1;
    if (s <= 0) Vb(Yb) ;
Vb(Xb) ;

The initial values of Xb and Yb are respectively
  • a)
    0 and 0
  • b)
    0 and 1
  • c)
    1 and 0
  • d)
    1 and 1
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
The P and V operations on counting semaphores, where s is a counting s...
Suppose Xb = 0, then because of P(s): Pb(Xb) operation, Xb will be -1 and processs will get blocked as it will enter into waiting section. So, Xb will be one. Suppose s=2(means 2 process are accessing shared resource), taking Xb as 1,
first P(s): Pb(Xb) operation will make Xb as zero. s will be 1 and Then Vb(Xb) operation will be executed which will increase the count of Xb as one. Then same process will be repeated making Xb as one and s as zero.
Now suppose one more process comes, then Xb will be 1 but s will be -1 which will make this process go into loop (s <0) and will result into calling Vb(Xb) and Pb(Yb) operations. Vb(Xb) will result into Xb as 2 and Pb(Yb) will result into decrementing the value of Yb.
case 1: if Yb has value as 0, it will be -1 and it will go into waiting and will be blocked.total 2 process will access shared resource (according to counting semaphore, max 3 process can access shared resource) and value of s is -1 means only 1 process will be waiting for resources and just now, one process got blocked. So it is still true.
case 2: if Yb has value as 1, it will be 0. Total 3 process will access shared resource (according to counting semaphore, max 3 process can access shared resource) and value of s is -1 means only 1 process will be waiting for resources and but there is no process waiting for resources.So it is false.
View all questions of this test
Most Upvoted Answer
The P and V operations on counting semaphores, where s is a counting s...
Explanation:
The counting semaphore operations P(s) and V(s) are implemented using two binary semaphores Xb and Yb.

Initial values:
The initial values of Xb and Yb are given as 1 and 0, respectively.

P(s) operation:
1. The process executes the Pb(Xb) operation, which checks if Xb is 1. If Xb is 0, the process waits.
2. The process then subtracts 1 from the value of s.
3. If the value of s is greater than or equal to 0, the process executes the Vb(Xb) operation, which sets the value of Xb to 1.
4. The process then executes the Pb(Yb) operation, which checks if Yb is 1. If Yb is 0, the process waits.
5. After the process is woken up, it continues execution.
6. Finally, the process executes the Vb(Xb) operation, which sets the value of Xb to 1.

V(s) operation:
1. The process executes the Pb(Xb) operation, which checks if Xb is 1. If Xb is 0, the process waits.
2. The process then adds 1 to the value of s.
3. If the value of s is 0, the process executes the Vb(Yb) operation, which sets the value of Yb to 1.
4. Finally, the process executes the Vb(Xb) operation, which sets the value of Xb to 1.

Final values:
After executing the P(s) and V(s) operations, the final values of Xb and Yb are 1 and 0, respectively.

Explanation of Option C:
The correct answer is option C, which states that the initial values of Xb and Yb are 1 and 0, respectively. This is because the P(s) operation requires the initial value of Xb to be 1, which allows the process to enter the critical section. The initial value of Yb is 0, which ensures that the process waits until it is woken up by the V(s) operation. Therefore, option C satisfies the requirements for implementing the semaphore operations P(s) and V(s) using binary semaphores.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. Can you explain this answer?
Question Description
The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. 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 P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. 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 P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. Can you explain this answer?.
Solutions for The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. 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 P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. Can you explain this answer?, a detailed solution for The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:P(s) : s = s - 1; if (s < 0) then wait;V(s) : s = s + 1; if (s <= 0) then wakeup a process waiting on s;Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:P(s) : Pb(Xb); s = s - 1; if (s < 0) { Vb(Xb) ; Pb(Yb) ;}else Vb(Xb);V(s) : Pb(Xb) ; s = s + 1; if (s <= 0) Vb(Yb) ;Vb(Xb) ;The initial values of Xb and Yb are respectivelya)0 and 0b)0 and 1c)1 and 0d)1 and 1Correct answer is option 'C'. 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