revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / addsemaphore.c
blobd61ee2da493db8b6eed5bfead4dfe07bff900a3b
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a semaphore to the public list of semaphores.
6 Lang: english
7 */
9 #include <exec/semaphores.h>
10 #include <proto/exec.h>
12 #include "exec_intern.h"
13 #include "exec_debug.h"
15 /*****************************************************************************
17 NAME */
19 AROS_LH1(void, AddSemaphore,
21 /* SYNOPSIS */
22 AROS_LHA(struct SignalSemaphore *, sigSem, A1),
24 /* LOCATION */
25 struct ExecBase *, SysBase, 100, Exec)
27 /* FUNCTION
28 Adds a semaphore to the system public semaphore list. Since the
29 semaphore gets initialized by this function it must be free at
30 this time. Also the ln_Name field must be set.
32 INPUTS
33 sigSem - Pointer to semaphore structure
35 RESULT
37 NOTES
38 Semaphores are shared between the tasks that use them and must
39 therefore lie in public (or at least shared) memory.
41 EXAMPLE
43 BUGS
45 SEE ALSO
47 INTERNALS
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
53 /* Initialize semaphore */
54 InitSemaphore(sigSem);
56 /* Arbitrate for the semaphore list */
57 Forbid();
58 #if defined(__AROSEXEC_SMP__)
59 EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase)->SemListSpinLock, NULL, SPINLOCK_MODE_WRITE);
60 #endif
61 /* Add the semaphore */
62 Enqueue(&SysBase->SemaphoreList,&sigSem->ss_Link);
63 #if defined(__AROSEXEC_SMP__)
64 EXEC_SPINLOCK_UNLOCK(&PrivExecBase(SysBase)->SemListSpinLock);
65 #endif
66 /* All done. */
67 Permit();
69 AROS_LIBFUNC_EXIT
70 } /* AddSemaphore */