From ad3d21e81592481539a56e93234f5bf1fa2c0504 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 16 Mar 2010 19:36:21 +0000 Subject: Documentation reorganization. Moved the description from kernel.dox into the source code for ease of editing and reference. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1746 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/src/chsem.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'os/kernel/src/chsem.c') diff --git a/os/kernel/src/chsem.c b/os/kernel/src/chsem.c index 9de6571d8..439412d7c 100644 --- a/os/kernel/src/chsem.c +++ b/os/kernel/src/chsem.c @@ -22,6 +22,28 @@ * @brief Semaphores code. * * @addtogroup semaphores + * @details Semaphores and threads synchronization. + * + *

Operation mode

+ * A semaphore is a threads synchronization object, some operations + * are defined on semaphores: + * - Signal: The semaphore counter is increased and if the + * result is non-positive then a waiting thread is removed from + * the semaphore queue and made ready for execution. + * - Wait: The semaphore counter is decreased and if the result + * becomes negative the thread is queued in the semaphore and + * suspended. + * - Reset: The semaphore counter is reset to a non-negative + * value and all the threads in the queue are released. + * . + * Semaphores can be used as guards for mutual exclusion code zones + * (note that mutexes are recommended for this kind of use) but also + * have other uses, queues guards and counters as example.
+ * Semaphores usually use a FIFO queuing strategy but it is possible + * to make them order threads by priority by enabling + * @p CH_USE_SEMAPHORES_PRIORITY in @p chconf.h.
+ * In order to use the Semaphores APIs the @p CH_USE_SEMAPHORES + * option must be enabled in @p chconf.h. * @{ */ -- cgit v1.2.3