Sync — C Library Procedures
NAME
Sync − Synchronization overview
SYNOPSIS
This section provides an overview of the Sprite Sync_ system routines.
DESCRIPTION
Sprite provides system calls to allow processes to synchronize execution using Mesa-style monitors.
The following set of macros are used to emulate monitored procedures of Mesa. The LOCK_MONITOR and UNLOCK_MONITOR macros depend on a constant LOCKPTR. LOCKPTR should be defined as the address of the lock variable used to lock the monitor. Something like the following two lines of code should appear at the beginning of a file of monitored procedures.
#include <sync.h>
Sync_Lock modMonitorLock;
#define LOCKPTR (&modMonitorLock)
The pseudo-keywords INTERNAL and ENTRY denote internal and entry procedures of a monitor. INTERNAL procedures can only be called when the monitor lock is held. ENTRY procedures are procedures that acquire the lock. There may also be External procedures. They are the default and there is no special keyword. An External procedure doesn’t explicitly acquire the monitor lock, but may call an ENTRY procedure.
Condition variables represent events that are associated with locks. The operations on a condition variable are Sync_Wait and Sync_Broadcast. Sync_Wait allows a process to wait for a particular monitor condition to occur. Sync_Broadcast wakes up all processes waiting on a particular condition. The lock must be acquired before a call to these routines is made. The lock is released while a process waits on a condition, and is then re-acquired when the condition is notified via Sync_Broadcast.
Sync_Broadcast is the only mechanism for awakening waiting processes. For example, there is no means to notify only a single process awaiting a particular condition. If several processes are awaiting the availability of a single shared resource, all processes awaiting the condition must be notified; they must each recheck for the availability of the resource, and all but one will find the resource unavailable and wait again.
Sync_WaitTime is used to cause the process to sleep for a specific amount of time. The process will be woken up if a signal arrives.
SEE ALSO
Sync_Broadcast, Sync_Wait, Sync_WaitTime
KEYWORDS
synchronization, wait, block, process, event, wakeup, broadcast
Sprite version 1.0 — December 30, 1988