The Gateway to Computer Science Excellence
0 votes
126 views
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?
in Operating System by Junior (559 points) | 126 views
0
Process executing signal(s) will be allowed to execute and also it will make value of s = 0,which will restrict any other process from entering critical section if they executes signal(s)
+1
@aekhn signal(s) increases the value, not decreases!
0
But in binary semaphore value of the semaphore can be 1 max, right?
0
@Akash Yes, please see my answer below.
0
yes I saw. thank you.

3 Answers

+1 vote

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

by Loyal (5.4k points)
0

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?
+1

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

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

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.
by (403 points)
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)

by Boss (36.7k points)

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
50,737 questions
57,398 answers
198,613 comments
105,456 users