Question:
semaphores in computers?
sibinps
2006-10-10 21:46:24 UTC
please help me to get details about "semaphores in computers."

please help
Four answers:
2006-10-10 21:50:58 UTC
http://en.wikipedia.org/wiki/Semaphore_(programming)
2006-10-10 21:51:06 UTC
A semaphore is a protected variable (or abstract data type) and constitutes the classic method for restricting access to equivalent shared resources (e.g. storage) in a multiprogramming environment. They were invented by Edsger Dijkstra and first used in the THE operating system.



The value of the semaphore is initialized to the number of equivalent shared resources it is implemented to control. In the special case where there is a single equivalent shared resource, the semaphore is called a binary semaphore. The general case semaphore is often called a counting semaphore.



Semaphores are the classic solution to the dining philosophers problem, although they do not prevent all deadlocks.



Semaphores can only be accessed using the following operations:



P(Semaphore s)

{

await s > 0, then s := s-1; /* must be atomic once s > 0 is detected */

}



V(Semaphore s)

{

s := s+1; /* must be atomic */

}



Init(Semaphore s, Integer v)

{

s := v;

}



Notice that incrementing the variable s must not be interrupted, and the P operation must not be interrupted after s is found to be nonzero. This can be done by special instruction (if the architecture's instruction set supports it) or by ignoring interrupts in order to prevent other processes from becoming active.



The canonical names P and V come from the initials of Dutch words. V stands for verhoog, or "increase." Several explanations have been given for P (including passeer "pass," probeer "try," and pakken "grab"), but in fact Dijkstra wrote that he intended P to stand for the made-up portmanteau word prolaag,[1] short for probeer te verlagen, or "try-and-decrease."[2][3] (A less ambiguous English translation would be "try-to-decrease.") This confusion stems from the unfortunate characteristic of the Dutch language that the words for increase and decrease both begin with the letter V, and the words spelled out in full would be impossibly confusing for non–Dutch-speakers.



The value of a semaphore is the number of units of the resource which are free. (If there is only one resource, a "binary semaphore" with values 0 or 1 is used.) The P operation busy-waits (or maybe sleeps) until a resource is available, whereupon it immediately claims one. V is the inverse; it simply makes a resource available again after the process has finished using it. Init is only used to initialize the semaphore before any requests are made. The P and V operations must be atomic, which means that no process may ever be preempted in the middle of one of those operations to run another operation on the same semaphore.



In English textbooks, and in the programming language ALGOL 68, the P and V operations are sometimes called, respectively, down and up. In software engineering practice they are called wait and signal, or take and release, or pend and post.



To avoid busy-waiting, a semaphore may have an associated queue of processes (usually a FIFO). If a process performs a P operation on a semaphore which has the value zero, the process is added to the semaphore's queue. When another process increments the semaphore by performing a V operation, and there are processes on the queue, one of them is removed from the queue and resumes execution.
karwankar
2006-10-10 22:08:47 UTC
A hardware or software flag. In multitasking systems, a semaphore is a variable with a value that indicates the status of a common resource. It's used to lock the resource that is being used. A process needing the resource checks the semaphore to determine the resource's status and then decides how to proceed.



Semaphore

A signal that is used to communicate the status of a shared resource. A semaphore is commonly a positive integer from 0 and higher, each value is a different status of that resource.

Apparatus and method for semaphore initialization in a multiprocessing computer system for process synchronization

Document Type and Number: United States Patent 4316245

Link to this Page: http://www.freepatentsonline.com/4316245.html

Abstract: Apparatus in a data processing system to initialize a semaphore held in a memory field of the data processing system or, alternatively, to restore the semaphore to a previous predetermined state. A count field, or tally field, provided in the semaphore is initialized by a particular instruction. The semaphore can be either a non-message semaphore or a message semaphore. The instruction initializes the semaphore count field of a non message semaphore to zero or a preloaded positive value. For a message semaphore, this instruction initializes the count field to zero. If the message semaphore previously had a positive count, the messages tied to the semaphore are released and the message links holding the messages are transferred to a free message link queue tied to the free link semaphore in the same semaphore descriptor segment. The apparatus includes a retrieving member for reading the content of the semaphore in the memory of the data processing system, a testing member for testing the count field of the semaphore for generating a first signal when the count field represents the number of processes in queue and a second signal when the count field represents the number of times a particular kind of event has occurred, a changing unit responsive to the second signal and controlled by the particular instruction for changing the number inside the count field to a predetermined number and a control member responsive to the first signal and controlled by the particular instruction for controlling the data processing system to cease execution of the particular instruction and to begin to execute a different instruction.





Following links will definatly help you
2006-10-10 21:49:10 UTC
After doing a quick search like you should have done, I found these.



http://www.cs.cf.ac.uk/Dave/C/node26.html



http://www.howtodothings.com/computers/a1319-semaphores.html


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...