aboutsummaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-07-26 09:25:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-07-26 09:25:11 +0000
commit69f9642bf44e6e3de680b07a22a290b9219ab47d (patch)
tree260cffa032b2d796e8bbabfa172d6c0c50ffd2b4 /src/include
parent868866157762bc5ad7644fcaa45111ecf6ed1899 (diff)
downloadChibiOS-69f9642bf44e6e3de680b07a22a290b9219ab47d.tar.gz
ChibiOS-69f9642bf44e6e3de680b07a22a290b9219ab47d.tar.bz2
ChibiOS-69f9642bf44e6e3de680b07a22a290b9219ab47d.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@359 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ch.h1
-rw-r--r--src/include/condvars.h56
-rw-r--r--src/include/lists.h5
-rw-r--r--src/include/threads.h48
4 files changed, 87 insertions, 23 deletions
diff --git a/src/include/ch.h b/src/include/ch.h
index cafcf2f75..4cf9c157f 100644
--- a/src/include/ch.h
+++ b/src/include/ch.h
@@ -35,6 +35,7 @@
#include "scheduler.h"
#include "semaphores.h"
#include "mutexes.h"
+#include "condvars.h"
#include "events.h"
#include "messages.h"
#include "threads.h"
diff --git a/src/include/condvars.h b/src/include/condvars.h
new file mode 100644
index 000000000..ec6c4589f
--- /dev/null
+++ b/src/include/condvars.h
@@ -0,0 +1,56 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT and Copyright (C) 2008 Leon Woestenberg.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @addtogroup Conditional Variables
+ * @{
+ */
+
+#ifndef _CONDVARS_H_
+#define _CONDVARS_H_
+
+#ifdef CH_USE_CONDVARS
+
+typedef struct CondVar CondVar;
+
+struct CondVar {
+ /** Queue of the threads sleeping on this CondVar. */
+ ThreadsQueue c_queue;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chCondInit(CondVar *cp);
+ void chCondSignal(CondVar *cp);
+ void chCondSignalS(CondVar *cp);
+ void chCondBroadcast(CondVar *cp);
+ void chCondBroadcastS(CondVar *cp);
+ msg_t chCondWait(CondVar *cp, Mutex *mp);
+ msg_t chCondWaitS(CondVar *cp, Mutex *mp);
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* CH_USE_CONDVARS */
+
+#endif /* _CONDVARS_H_ */
+
+/** @} */
diff --git a/src/include/lists.h b/src/include/lists.h
index 08f574393..d98892600 100644
--- a/src/include/lists.h
+++ b/src/include/lists.h
@@ -35,9 +35,9 @@ typedef struct Thread Thread;
* Generic threads queue header and element.
*/
typedef struct {
- /** First \p Thread in the queue.*/
+ /** First \p Thread in the queue, or \p ThreadQueue when empty. */
Thread *p_next;
- /** Last \p Thread in the queue.*/
+ /** Last \p Thread in the queue, or \p ThreadQueue when empty. */
Thread *p_prev;
} ThreadsQueue;
@@ -45,6 +45,7 @@ typedef struct {
* Generic threads single link list, it works like a stack.
*/
typedef struct {
+ /** Last pushed \p Thread on the stack list, or \p ThreadList when empty. */
Thread *p_next;
} ThreadsList;
diff --git a/src/include/threads.h b/src/include/threads.h
index b7b1a3e29..76e8d480e 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -67,6 +67,10 @@ struct Thread {
/** Mutex where the thread is waiting on (only in \p PRWTMTX state). */
Mutex *p_wtmtxp;
#endif
+#ifdef CH_USE_CONDVARS
+ /** CondVar where the thread is waiting on (only in \p PRWTCOND state). */
+ CondVar *p_wtcondp;
+#endif
#ifdef CH_USE_MESSAGES
/** Destination thread for message send (only in \p PRSNDMSG state). */
Thread *p_wtthdp;
@@ -85,11 +89,11 @@ struct Thread {
* Start of the optional fields.
*/
#ifdef CH_USE_WAITEXIT
- /** The list of the threads waiting for this thread termination.*/
+ /** The list of the threads waiting for this thread termination. */
ThreadsList p_waiting;
#endif
#ifdef CH_USE_EXIT_EVENT
- /** The thread termination \p EventSource.*/
+ /** The thread termination \p EventSource. */
EventSource p_exitesource;
#endif
#ifdef CH_USE_MESSAGES
@@ -97,39 +101,41 @@ struct Thread {
msg_t p_msg;
#endif
#ifdef CH_USE_EVENTS
- /** Pending events mask.*/
+ /** Pending events mask. */
eventmask_t p_epending;
#endif
#ifdef CH_USE_MUTEXES
- /** List of mutexes owned by this thread, \p NULL terminated.*/
+ /** List of mutexes owned by this thread, \p NULL terminated. */
Mutex *p_mtxlist;
- /** Thread's own, non-inherited, priority */
+ /** Thread's own, non-inherited, priority. */
tprio_t p_realprio;
#endif
};
-/** Thread state: Thread in the ready list.*/
+/** Thread state: Ready to run, waiting on the ready list.*/
#define PRREADY 0
-/** Thread state: Current.*/
+/** Thread state: Currently running. */
#define PRCURR 1
-/** Thread state: Thread created in suspended state.*/
+/** Thread state: Thread created in suspended state. */
#define PRSUSPENDED 2
-/** Thread state: Waiting on a semaphore.*/
+/** Thread state: Waiting on a semaphore. */
#define PRWTSEM 3
-/** Thread state: Waiting on a mutex.*/
+/** Thread state: Waiting on a mutex. */
#define PRWTMTX 4
-/** Thread state: Waiting in \p chThdSleep() or \p chThdSleepUntil().*/
-#define PRSLEEP 5
-/** Thread state: Waiting in \p chThdWait().*/
-#define PRWAIT 6
-/** Thread state: Waiting in \p chEvtWait().*/
-#define PRWTEVENT 7
-/** Thread state: Waiting in \p chMsgSend().*/
-#define PRSNDMSG 8
-/** Thread state: Waiting in \p chMsgWait().*/
-#define PRWTMSG 9
+/** Thread state: Waiting on a condition variable. */
+#define PRWTCOND 5
+/** Thread state: Waiting in \p chThdSleep() or \p chThdSleepUntil(). */
+#define PRSLEEP 6
+/** Thread state: Waiting in \p chThdWait(). */
+#define PRWAIT 7
+/** Thread state: Waiting in \p chEvtWait(). */
+#define PRWTEVENT 8
+/** Thread state: Waiting in \p chMsgSend(). */
+#define PRSNDMSG 9
+/** Thread state: Waiting in \p chMsgWait(). */
+#define PRWTMSG 10
/** Thread state: After termination.*/
-#define PREXIT 10
+#define PREXIT 11
#ifdef CH_USE_TERMINATE
/** Thread option: Termination requested flag.*/