answersLogoWhite

0

A semaphore is a service very often offered by real-time operating systems to allow programmers to perform one of two major functions: synchronize 2 tasks or control sharing of resources between 2 or more tasks. There are different kinds of semaphores, but one of the most common is called a binary semaphore. In this kind of semaphore, only 1 task at a time may "have" the semaphore. The simplest way to think of the binary semaphore might be to consider the semaphore like a baton and there is only one baton. Say if you want to allow only 1 person to speak at a time (consider people to be tasks), then you make a rule that only the person holding the baton may speak. A person wanting to speak will go and pick up the baton. If nobody else has it, he may speak. If someone else has it, he must wait until the baton is put down by whoever has it. This is the "sharing resources" way a semaphore is used. The task synchronization usage, similarly can be thought of using this baton. Just as in a relay race where one person cannot start until another passes the baton, a binary semaphore can be used to synchronize two tasks by giving one task the semaphore, having the second one wait for the semaphore, and then having the first give it to the second. The two tasks will be synchronized at the point the semaphore is passed from the first to the second just as a baton is passed from one runner to the next in a relay race. You can have semaphores other than binary semaphores, which are called counting semaphores. Counting semaphores are just binary semaphores generalized to more than the 2 values of 0 and 1, to some value n.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

The virtual machine concept calls for multiprogramming or time sharing at the what level?

Operating System level.


What is the principal disadvantge of too much multiprogramming?

The principal disadvantge of too much multiprogramming is the overhead of excesssive context-switching. If the context-switch rate is too high, the overhead can actually overwhelm the benefit of multiprogramming.


What are advantages of multiprogramming?

Multiprogramming makes effifcient use of the CPU by overlapping the demands for the CPU and its I/O devices from various users. It attempts to increase CPU utilization by always having something for the CPU to execute.


'What is the difference between multiprogramming and multitasking and what is meaning of a task if we consider a task as a program then the concept will be multiprogramming then what is the differenc?

First of all there is difference between program and a task. There may be multiple tasks running related to one program at the same time. so if the processor is busy in multiple tasks related to one program then it is multitasking. But if the multiple tasks which the processor is executing concurrently are related to different independent programs then the concept is know as multiprogramming.


Is windows operating system multiprogramming or multitasking?

multiprogramming


When was THE multiprogramming system created?

THE multiprogramming system was created in 1968.


Explain Briefly Concept of Toning In Computer Graphics?

explain concept toning computergraphics


Explain the concept of management and bring out is importanc in present day organizations?

explain the concept of managemen


Is multitasking a logical extension of multiprogramming?

timesharing is logical extention of multiprogramming.


Explain binary semaphore and its uses?

A binary semaphore is a semaphore with an integer value that can range only between 0 and 1. A binary semaphore can be simpler to implement than a counting semaphore, depending on the underlying hardware architecture.To implement it in terms of binary semaphores we need the following data structures: binary-semaphore S1, S2; i n t C; Initially S1 = 1, S2 = 0, and the value of integer C is set to the initial value of the counting semaphore S.The wait operation on the counting semaphore S can be implemented as follows: wait (S1) ; c--; i f (C < 0) { signal(S1) ; wait (S2) ; } signal(S1) The signal operation on the counting semaphore S can be implemented as follows: w a i t (S1) ; C++ ; i f (C <= 0) signal (S2) ; e l s e signal (S1) ;


How many semaphore flag methods are there?

there are 28 semaphore flag methods.


What is the initial value of semaphore?

The initial value of a semaphore is typically set by the programmer when the semaphore is initialized. This value determines the number of concurrent threads or processes that can access a shared resource protected by the semaphore at the same time.