Exec semaphores are signal based. Using signal semaphores is the easiest
way to protect shared, single-access resources in the Amiga. Your task
will sleep until the semaphore is available for use. The signalsemaphore
structure is as follows:
struct SignalSemaphore {
struct Node ss_Link;
SHORT ss_NestCount;
struct MinList ss_WaitQueue;
struct SemaphoreRequest ss_MultipleLink;
struct Task *ss_Owner;
SHORT ss_QueueCount;
};
ss_Link
is the node structure used to link semaphores together. The ln_pri
and ln_name fields are used to set the priority of the semaphore in a
list and to name the semaphore for public access. if a semaphore is
not public the ln_Name and ln_Pri fields may be left NULL.
ss_NestCount
is the count of number of locks the current owner has on the
semaphore.
ss_WaitQueue
is the list header for the list of other tasks waiting for this
semaphore.
ss_MultipleLink
is the semaphorerequest used by obtainsemaphorelist().
ss_Owner
is the pointer to the current owning task.
ss_QueueCount
is the number of other tasks waiting for the semaphore.
A practical application of a SignalSemaphore would be to use it as the
base of a shared data structure. For example:
struct SharedList {
struct SignalSemaphore sl_Semaphore;
struct MinList sl_List;
};
creating a signalsemaphore structure
making a signalsemaphore available to the public
obtaining a signalsemaphore exclusively
obtaining a shared signalsemaphore
checking a signalsemaphore
releasing a signalsemaphore
removing a signalsemaphore structure