[Return to Top] [Standard Processes]

EROS Object Reference

Standard Processes

Semaphore

D R A F T

Description

The Semaphore object provides a mechanism for one process to sleep until another awakens it. An actor (a process) that wishes to delay until a provider (another process) has completed some operation invokes the semaphore object. When the provider has completed it's operation, it invokes the semaphore to awaken the actor.

A sempahore is in some sense the inverse of a mutex object. Where a mutex object ensures that only a single process can run, a semaphore ensures that only a single process is blocked.

Note that an invoker can wake up a previous invoker without sleeping by performing a fork rather than a call of the semaphore key.


Operations

Check Alleged Key Type (OC = KT)

Returns the alleged type of the key. This operation does not cause the caller to block.
ReplyR10x030000: Key is a semaphore object key.

Sleep (OC = 1)

Causes the invoker to go to sleep in the semaphore object, waking up any party that may already be asleep. On return, the caller may assume that the semaphore has been invoked by at least one other party.
Result0You are awake again.


Copyright 1998 by Jonathan Shapiro. All rights reserved. For terms of redistribution, see the GNU General Public License