Docs » Autodocs » exec.library » InitSemaphore
InitSemaphore -- initialize a signal semaphore
InitSemaphore(signalSemaphore) A0 void InitSemaphore(struct SignalSemaphore *);
This function initializes a signal semaphore and prepares it for use. It does not allocate anything, but does initialize list pointers and the semaphore counters. Semaphores are often used to protect critical data structures or hardware that can only be accessed by one task at a time. After initialization, the address of the SignalSemaphore may be made available to any number of tasks. Typically a task will try to ObtainSemaphore(), passing this address in. If no other task owns the semaphore, then the call will lock and return quickly. If more tasks try to ObtainSemaphore(), they will be put to sleep. When the owner of the semaphore releases it, the next waiter in turn will be woken up. Semaphores are often preferable to the old-style Forbid()/Permit() type arbitration. With Forbid()/Permit() *all* other tasks are prevented from running. With semaphores, only those tasks that need access to whatever the semaphore protects are subject to waiting.
signalSemaphore -- a signal semaphore structure (with all fields set to zero before the call)
ObtainSemaphore(), ObtainSemaphoreShared(), AttemptSemaphore(), ReleaseSemaphore(), Procure(), Vacate(), <exec/semaphores.h>
|