What is a semaphore?

Answers were Sorted based on User's Feedback



What is a semaphore?..

Answer / swetcha

Semaphores r software, blocking, OS assistance solution to
the mutual exclusion problem .It is
basically a non-negative integer variable that saves the
number of wakeup signals sent so they are not lost if the
process is not sleeping

another interpretation is that the semaphore value
represents the number of resources available

Is This Answer Correct ?    101 Yes 34 No

What is a semaphore?..

Answer / jethva_trupti

A semaphore, a new variable type.
A semaphore could have the value 0,indicating that no
wakeups were saved, or some positive values if one or more
wakeups were pending.
a semaphore s is an integer variable that apart from
initialization, is accesssed only through two standard
atomic operations, wait and signal. these operations were
orignially termed p(for wait to test) and v(for signal to
increment).
The classical defination of wait in psedocode is
wait(s)
{
while(s<=0)
;// no-op
s--;
}
The classical defination of signal in psedocode is
signal(s)
{
s++;
}
Modification to the integer value of smaphore in wait and
signal operations must be executed individually.
that is, when one process modifies the semaphore value no
other process can simultaneously modifiy that same
semaphore value.

Is This Answer Correct ?    68 Yes 11 No

What is a semaphore?..

Answer / kwrtos

Semaphore is a machanism to resolve resources conflicts by
tallying resource seekers what is the state of sought
resources, achieving a mutual exclusive access to resources.
Often semaphore operates as a type of mutual exclusive
counters (such as mutexes) where it holds a number of access
keys to the resources. Process that seeks the resources must
obtain one of those access keys, one of semaphores, before
it proceeds further to utilize the resource. If there is no
more such a key available to the process, it has to wait for
the current resource user to release the key.

Is This Answer Correct ?    66 Yes 25 No

What is a semaphore?..

Answer / sagarika mishra

In computer science, a semaphore is a protected variable or
abstract data type which constitutes the classic method for
restricting access to shared resources such as shared
memory in a multiprogramming environment. A counting
semaphore is a counter for a set of available resources,
rather than a locked/unlocked flag of a single resource. It
was invented by Edsger Dijkstra. Semaphores are the classic
solution to preventing race conditions in the dining
philosophers problem, although they do not prevent resource
deadlocks.
Semaphores can only be accessed using the following
operations. Those marked atomic should not be interrupted
(that is, if the system decides that the "turn is up" for
the program doing this, it shouldn't stop it in the middle
of those instructions) for the reasons explained below.
P(Semaphore s) // Acquire Resource
{
wait until s > 0, then s := s-1;
/* must be atomic because of race conditions */
}

V(Semaphore s) // Release Resource
{
s := s+1; /* must be atomic */
}

Init(Semaphore s, Integer v)
{
s := v;
}

Is This Answer Correct ?    29 Yes 12 No

What is a semaphore?..

Answer / chinnadurai.s

Synchronization tool that does not require busy waiting
Semaphore S–integer variable
Two standard operations modify S: wait()and signal()
Originally called P()andV()
Less complicated
Can only be accessed via two indivisible (atomic) operations

wait (S)
{
while S <= 0;
// no-op
S--;
}
&#61548;signal (S)
{
S++;
}

Is This Answer Correct ?    23 Yes 11 No

What is a semaphore?..

Answer / mahi 27

"semaphore " is an integer value that provide signalling
among the process
and it is an synchronization tool
semaphores are proposed by "DIJKSTRA"
generally semaphores are divided into 2 types
they are 1.General semaphore(or)counting semaphore
2.Binary semaphore(or)Mutex
in general semaphores 2 primitives are used they are
1.semwait(s)
2.semsignal(s)
semwait() checks decrements the semaphore value if the value
becomes negative then the process executing the semwait()is
blocked other wise the process continues execution
semsignal() increments the semaphore value if the value is
less than or equal to zero then a process blocked by a
semwait()operation is unblocked

Is This Answer Correct ?    18 Yes 9 No

What is a semaphore?..

Answer / kondepati

->synchronization tool that does not require busy writing.
->semaphore S-integer variable
->can only be accessesd via two indivisible(atomic) operations
wait(S):while S<=0 do no-op;
S:=s-1;
signal(S):S+1;
semaphores are of two types

COUNTING SEMAPHORE-integer value can range over an
unrestricted domain.

BINARY SEMAPHORE-integer value can range only between 0 and
1;can be simpler to implement.

can implement a counting semaphore S as a binary semaphore.

Is This Answer Correct ?    10 Yes 6 No

What is a semaphore?..

Answer / thangavelu t

semaphore is integer variable that used to achieve mutual
exclusion.
it always indicates no of resource instances available.

programming example:
code
{
acquire(s);
critical region;
release(s);
}

acquire(semaphore s)
{
while(s==0);
s--;
}
release(semaphore s)
{
s++;
}
init(semaphore s,int instances)
{
s=instances;//initializes to no of resources instances
}

Is This Answer Correct ?    7 Yes 3 No

What is a semaphore?..

Answer / gaurav

Semaphore is a variable which ios used to provide mutual
exclusion. It has two operations namely wait() and signal()

Is This Answer Correct ?    15 Yes 14 No

What is a semaphore?..

Answer / ragavendran

Semaphores are devices used to help with synchronization. If
multiple processes share a common resource, they need a way
to be able to use that resource without disrupting each
other. You want each process to be able to read from and
write to that resource uninterrupted.

A semaphore will either allow or disallow access to the
resource, depending on how it is set up. One example setup
would be a semaphore which allowed any number of processes
to read from the resource, but only one could ever be in the
process of writing to that resource at a time.

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More Operating Systems AllOther Interview Questions

How much memory do I need on my laptop?

0 Answers  


Where can I get a free operating system?

0 Answers  


what is multitask win95

0 Answers  


Method used for Disk searching.. a.linked list b.AVL c.B-tree d. binary tree

3 Answers   Hughes, KKR,


Why is android better than ios?

0 Answers  






How do you find out computer specs?

0 Answers  


How do you reset the bios?

0 Answers  


What causes a corrupt operating system?

0 Answers  


Can I put an ssd in my old computer?

0 Answers  


1) What is an Virtual memory? 2) How do we test API's in both Windows/Linux/Unix? 3) What is an IOCTL? 4) How do you open a char device through API's? 5) What is major num/ minor num? 6) What is the max num for minor num? 7) Who gives you the major / minor numbers? 8) Reverse a string using recursive func. 9) fork/vfork/clone. 10) What does fork returns? 11) What is a zombie process? 12) What happens when a child completes before parent tries to wait for it? 13) Interrupt handlers, top-hdnl....?

0 Answers   TCS, Wipro,


Can I close my computer while updating?

0 Answers  


Can I delete old updates to free up disk space?

0 Answers  


Categories