2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Release a lock obtained with Procure().
8 #include <exec/lists.h>
9 #include <exec/semaphores.h>
10 #include <proto/exec.h>
11 #include "semaphores.h"
12 #include "exec_intern.h"
14 /*****************************************************************************
18 AROS_LH2(void, Vacate
,
21 AROS_LHA(struct SignalSemaphore
*, sigSem
, A0
),
22 AROS_LHA(struct SemaphoreMessage
*, bidMsg
, A1
),
25 struct ExecBase
*, SysBase
, 91, Exec
)
28 Release a lock obtained with Procure. This will even work if the
29 message is not yet replied - the request will be cancelled and the
30 message replied. In any case the ssm_Semaphore field will be set to
34 sigSem - Pointer to semaphore structure.
35 bidMsg - Pointer to struct SemaphoreMessage.
50 *****************************************************************************/
54 struct SemaphoreRequest
*sr
= NULL
;
56 /* Arbitrate for the semaphore structure */
58 bidMsg
->ssm_Semaphore
= NULL
;
61 * Two cases, the request is in the list, which means it hasn't been
62 * granted, or the request is not in the list, in which case it has
63 * been granted. We need to check if the request is in the list.
65 ForeachNode(&sigSem
->ss_WaitQueue
, sr
)
67 if (sr
== (struct SemaphoreRequest
*)bidMsg
)
69 /* Found it. Remove it from the semaphore's waiting queue. */
70 Remove(&bidMsg
->ssm_Message
.mn_Node
);
71 sigSem
->ss_QueueCount
--;
73 /* And reply the message. */
74 ReplyMsg(&bidMsg
->ssm_Message
);
82 /* No, it must have been fulfilled. Release the semaphore and done. */
83 ReleaseSemaphore(sigSem
);