2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Initialize a SignalSemaphore
9 #include "exec_intern.h"
10 #include <exec/semaphores.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
17 AROS_LH1I(void, InitSemaphore
,
20 AROS_LHA(struct SignalSemaphore
*, sigSem
, A0
),
23 struct ExecBase
*, SysBase
, 93, Exec
)
26 Prepares a semaphore structure for use by the exec semaphore system,
27 i.e. this function must be called after allocating the semaphore and
28 before using it or the semaphore functions will fail.
31 sigSem - Pointer to semaphore structure
36 Semaphores are shared between the tasks that use them and must
37 therefore lie in public (or at least shared) memory.
47 *****************************************************************************/
51 /* Clear list of wait messages */
52 sigSem
->ss_WaitQueue
.mlh_Head
= (struct MinNode
*)&sigSem
->ss_WaitQueue
.mlh_Tail
;
53 sigSem
->ss_WaitQueue
.mlh_Tail
= NULL
;
54 sigSem
->ss_WaitQueue
.mlh_TailPred
= (struct MinNode
*)&sigSem
->ss_WaitQueue
.mlh_Head
;
56 /* Set type of Semaphore */
57 sigSem
->ss_Link
.ln_Type
= NT_SIGNALSEM
;
59 /* Semaphore is currently unused */
60 sigSem
->ss_NestCount
= 0;
62 /* Semaphore has no owner yet */
65 /* Semaphore has no queue */
66 sigSem
->ss_QueueCount
= -1;
68 #if defined(__AROSEXEC_SMP__)
69 EXEC_SPINLOCK_INIT(&sigSem
->ss_MultipleLink
.sr_SpinLock
);