diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2007-09-28 18:42:04 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2007-09-28 18:42:04 +0000 |
commit | 9a0ef300bce50901d5de3d6d722e29b79a2f9a36 (patch) | |
tree | 3f6ba1c9a49c9534d931bbc33baff4368ce25d26 /src/include/threads.h | |
parent | 95b238fc867da32f28c74b98b793fbd40345b595 (diff) | |
download | ChibiOS-9a0ef300bce50901d5de3d6d722e29b79a2f9a36.tar.gz ChibiOS-9a0ef300bce50901d5de3d6d722e29b79a2f9a36.tar.bz2 ChibiOS-9a0ef300bce50901d5de3d6d722e29b79a2f9a36.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@25 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/include/threads.h')
-rw-r--r-- | src/include/threads.h | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/src/include/threads.h b/src/include/threads.h index f170ce368..688ce579a 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -182,19 +182,55 @@ static INLINE void enqueue(Thread *tp, ThreadsQueue *tqp) { /*
* Threads APIs.
*/
-#define chThdSelf() currp
Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
t_size wsize, t_tfunc pf, void *arg);
void chThdResume(Thread *tp);
-void chThdTerminate(Thread *tp);
-BOOL chThdShouldTerminate(void);
-BOOL chThdTerminated(Thread *tp);
void chThdExit(t_msg msg);
+
+/** Returns the pointer to the \p Thread currently in execution.*/
+#define chThdSelf() currp
+
+/** Returns the pointer to the \p Thread local storage area, if any.*/
+#define chThdLS() (void *)(currp + 1)
+
+/** Verifies if the specified thread is in the \p PREXIT state.*/
+#define chThdTerminated(tp) ((tp)->p_state == PREXIT)
+
+#ifdef CH_USE_TERMINATE
+/**
+ * Verifies if the current thread has a termination request pending.
+ */
+#define chThdShouldTerminate() (currp->p_flags & P_TERMINATE)
+
+void chThdTerminate(Thread *tp);
+#endif
+
#ifdef CH_USE_WAITEXIT
t_msg chThdWait(Thread *tp);
#endif
+
#ifdef CH_USE_EXIT_EVENT
-EventSource *chThdGetExitEventSource(Thread *tp);
+/**
+ * Returns the exit event source for the specified thread. The source is
+ * signaled when the thread terminates.
+ * @param tp the pointer to the thread
+ * @note When registering on a thread termination make sure the thread
+ * is still alive, if you do that after the thread termination
+ * then you would miss the event. There are two ways to ensure
+ * this:<br>
+ * <ul>
+ * <li>Create the thread suspended, register on the event source
+ * and then resume the thread (recommended).</li>
+ * <li>Create the thread with a lower priority then register on it.
+ * This does not work if the hardware is capable of multiple
+ * physical threads.</li>
+ * </ul>
+ * @note You dont need to unregister from a terminated thread because
+ * the event source becomes inactive.
+ * @note The function is available only if the \p CH_USE_EXIT_EVENT
+ * option is enabled in \p chconf.h.
+ */
+#define chThdGetExitEventSource(tp) (&(tp)->p_exitesource)
#endif
#endif /* _THREADS_H_ */
|