Updated from its repository.
[cake.git] / workbench / libs / thread / lockmutex.c
blob5f313c949978f2925aa744e0e290e97160d456e3
1 /*
2 * thread.library - threading and synchronisation primitives
4 * Copyright © 2007 Robert Norris
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
8 */
10 #include "thread_intern.h"
12 #include <exec/semaphores.h>
13 #include <proto/exec.h>
14 #include <assert.h>
16 /*****************************************************************************
18 NAME */
19 AROS_LH1(void, LockMutex,
21 /* SYNOPSIS */
22 AROS_LHA(void *, mutex, A0),
24 /* LOCATION */
25 struct ThreadBase *, ThreadBase, 12, Thread)
27 /* FUNCTION
28 Locks a mutex. If the lock is already held, this function blocks.
30 INPUTS
31 mutex - mutex to lock.
33 RESULT
34 This function always succeeds.
36 NOTES
38 EXAMPLE
39 LockMutex(mutex);
41 BUGS
43 SEE ALSO
44 CreateMutex(), DestroyMutex(), TryLockMutex(), UnlockMutex()
46 INTERNALS
47 Mutexes are implemented as thin wrappers around Exec semaphores.
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
53 assert(mutex != NULL);
55 ObtainSemaphore((struct SignalSemaphore *) mutex);
57 AROS_LIBFUNC_EXIT
58 } /* LockMutex */