0 votes 0 votes if s is a binary semaphore and the initial value of s is 1 then can 'signal' be performed on s ? what will happen if signal(s) is performed? Operating System operating-system semaphore + – Akash Kumar Roy asked Mar 24, 2018 Akash Kumar Roy 1.2k views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments Akash Kumar Roy commented Mar 24, 2018 reply Follow Share But in binary semaphore value of the semaphore can be 1 max, right? 0 votes 0 votes Akhilesh Singla commented Mar 24, 2018 reply Follow Share @Akash Yes, please see my answer below. 0 votes 0 votes Akash Kumar Roy commented Mar 24, 2018 reply Follow Share yes I saw. thank you. 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes Use of signal(s) releases the lock by increasing the value of semaphore by 1. It is performed by a process which is exiting from a critical section. Answer to your question is Yes, signal(s) can be performed. Since it is a binary semaphore, even performing signal(s), i.e., increasing s by 1, won't exceed the value of s from 1. Visit this: https://en.wikibooks.org/wiki/Operating_System_Design/Processes/Semaphores Akhilesh Singla answered Mar 24, 2018 Akhilesh Singla comment Share Follow See all 3 Comments See all 3 3 Comments reply Akash Kumar Roy commented Mar 24, 2018 reply Follow Share Then it means that in the following problem after p10 performs signal on 'mutex' and exits. After that, if any other process in the critical section also can perform signal on 'mutex' and can exit, right? Although I know that to have max process in critical section we can hold other processes in the critical section. Each Process Pi, i = 1....9 is coded as follows repeat P(mutex) {Critical section} V(mutex) forever The code for P10 is identical except it uses V(mutex) in place of P(mutex). What is the largest number of processes that can be inside the critical section at any moment? 0 votes 0 votes Akhilesh Singla commented Mar 24, 2018 reply Follow Share There can be two answers depending on how complex & deep we want to go. CASE 1: Considering in the question they are implementing mutex exactly same as a binary semaphore, then: Yes, after P10 performs signal(or V) on 'mutex' it makes/keeps the value of mutex to/as 1 and exits. After that, if any other process in the critical section perform signal on 'mutex' then that process will also exit by keeping the value of mutex as 1. P1 to P9 has: P10 has: P(mutex) /* same as wait(mutex) */ V(mutex) <CS> <CS> V(mutex) /* same as signal(mutex) */ V(mutex) Considering binary semaphore here. If we trace out then we will see that at max we can have all 10 processes in the CS at a moment because we can use P10 repeatedly. In one iteration of P10 it is allowing two processes from P1-P9 to get inside the CS. CASE 2: The thing is binary semaphore is different than mutex. See this: https://en.wikipedia.org/wiki/Semaphore_(programming)#Semaphores_vs._mutexes This means P() is saving process-id of the process performing the operation. P10 will never enter CS because it is not locking mutex using P() such that its process-id is being saved by the mutex. Since P10 is performing V() first, it will be denied as process-ids won't match, indicating some problem in the implementation. And thus, we will have only one process inside the CS at any moment. Generally, Case 1 will be your answer for any written exams. But in interviews, Case 2(along with Case 1) will look better. 1 votes 1 votes Ayush Upadhyaya commented Mar 28, 2018 reply Follow Share If a binary semaphore has a value 1 and Signal is called on the semaphore then nothing will happen and one signal operation will be lost.This may be a cause of concern where each and every signal operation counts and loosing even one may cause you to lose synchronization. A good example on this is below gate problem. https://gateoverflow.in/1550/gate2013-39 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes If value of binary semaphore is 1 then there is no process in the critical section then why will signal(s) be executed. priyanka boral answered Mar 24, 2018 priyanka boral comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes if s is a binary semaphore and the initial value of s is 1 then after performing 1 signal operation then it will remains same( one successful operation) abhishekmehta4u answered Mar 24, 2018 abhishekmehta4u comment Share Follow See all 0 reply Please log in or register to add a comment.