Example of semaphore, Operating System

For example, by initializing a semaphore to 0, threads can wait for an event to occur, and impose an ordering constraint, similar to a monitor using condition variables, but with memory: semaphore sem=0; // 0==locked for a semaphore


thread A
down(sem) // wait for thread B; note sem has memory!
// do stuff
thread B
// do stuff, then wake up A
up(sem)

Posted Date: 3/12/2013 5:23:25 AM | Location : United States







Related Discussions:- Example of semaphore, Assignment Help, Ask Question on Example of semaphore, Get Answer, Expert's Help, Example of semaphore Discussions

Write discussion on Example of semaphore
Your posts are moderated
Related Questions
Define Segmentation  The memory allocation method subject to “external” fragmentation is Segmentation.

Using pages makes it easier to manage the whole memory, avoiding excessive fragmentation and waste. As an analogy, think of Tetris, but with only square blocks: it is relatively ea

Direct communication With direct communication each process that requires to communicate must explicitly name the recipient or sender of the communication. The send and receive

How can the deadlock be prevented Bankers algorithm : The Resource allocation graph algorithm isn't applicable to a resource allocation system with multiple instances of every

Removing System Dependencies Because portions of the client - server application program may execute on different machines, it is very important for the developer to remove the

DIFFERENT MULTITHREADING MODELS Multithreading Models the majority multithreading models fall into one of the following categories of threading implementation: 1.      M

As we already know, threadsmust ensure consistency; otherwise, race conditions (non-deterministic results) might happen. Now consider the "too much milk problem": two people share

What is critical section problem? Consider a system consists of 'n' processes. Every process has segment of code called a critical section, in which the process might be changi

Operations that are to be performed on a directory are Search for a file: We are able to find all files whose names match a exact pattern. Create a file: New files requi

Forking is an important phase of Unix, critical to the support of its design strategies, which encourages the implementation of filters. In Unix, a filter is a process that reads i