aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-09-28 18:42:04 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-09-28 18:42:04 +0000
commit9a0ef300bce50901d5de3d6d722e29b79a2f9a36 (patch)
tree3f6ba1c9a49c9534d931bbc33baff4368ce25d26 /src
parent95b238fc867da32f28c74b98b793fbd40345b595 (diff)
downloadChibiOS-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')
-rw-r--r--src/chsleep.c4
-rw-r--r--src/chthreads.c49
-rw-r--r--src/include/threads.h46
-rw-r--r--src/templates/chcore.c2
-rw-r--r--src/templates/chcore.h4
5 files changed, 46 insertions, 59 deletions
diff --git a/src/chsleep.c b/src/chsleep.c
index 9fedd0244..5814410f3 100644
--- a/src/chsleep.c
+++ b/src/chsleep.c
@@ -62,11 +62,11 @@ t_time chSysGetTime(void) {
* option is enabled in \p chconf.h.
*/
void chThdSleepUntil(t_time time) {
- VirtualTimer t;
+ VirtualTimer vt;
chSysLock();
- chVTSetI(&t, (t_time)(time - stime), (t_vtfunc)chSchReadyI, currp);
+ chVTSetI(&vt, (t_time)(time - stime), (t_vtfunc)chSchReadyI, currp);
chSchGoSleepI(PRSLEEP);
chSysUnlock();
diff --git a/src/chthreads.c b/src/chthreads.c
index 59c361116..a439eb5b4 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -129,17 +129,6 @@ Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
return tp;
}
-/**
- * Verifies if the specified thread is in the \p PREXIT state.
- * @param tp the pointer to the thread
- * @return \p TRUE if the thread is ended else \p FALSE. \p TRUE ensures that
- * a subsequent call to \p chThdWait() would not block.
- */
-BOOL chThdTerminated(Thread *tp) {
-
- return tp->p_state == PREXIT;
-}
-
#ifdef CH_USE_RESUME
/**
* Resumes a thread created with the \p P_SUSPENDED option.
@@ -176,17 +165,6 @@ void chThdTerminate(Thread *tp) {
chSysUnlock();
}
-
-/**
- * Verifies if the current thread has a termination request pending.
- * @return \p TRUE if the termination was requested. The thread should terminate
- * as soon it is ready to do so.
- */
-BOOL chThdShouldTerminate(void) {
-
- return currp->p_flags & P_TERMINATE ? TRUE : FALSE;
-}
-
#endif
/**
@@ -234,31 +212,4 @@ t_msg chThdWait(Thread *tp) {
}
#endif /* CH_USE_WAITEXIT */
-#ifdef CH_USE_EXIT_EVENT
-/**
- * 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.
- */
-EventSource *chThdGetExitEventSource(Thread *tp) {
-
- return &tp->p_exitesource;
-}
-#endif /* CH_USE_EXIT_EVENT */
-
/** @} */
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_ */
diff --git a/src/templates/chcore.c b/src/templates/chcore.c
index 29a809378..e23cf1bfe 100644
--- a/src/templates/chcore.c
+++ b/src/templates/chcore.c
@@ -37,7 +37,7 @@
void chSysPause(void) {}
/**
- * Abonormal system termination handler. Invoked by the ChobiOS/RT when an
+ * Abonormal system termination handler. Invoked by the ChibiOS/RT when an
* abnormal unrecoverable condition is met.
*/
void chSysHalt(void) {}
diff --git a/src/templates/chcore.h b/src/templates/chcore.h
index 895e2b685..bb901b1ec 100644
--- a/src/templates/chcore.h
+++ b/src/templates/chcore.h
@@ -39,7 +39,7 @@ struct stackregs {
}
/**
- * Enters the ChobiOS/RT system mutual exclusion zone, the implementation is
+ * Enters the ChibiOS/RT system mutual exclusion zone, the implementation is
* architecture dependent, on single core systems usually this function
* just disables the interrupts.
* @note The code in the system mutual exclusion zone must be as light and
@@ -50,7 +50,7 @@ struct stackregs {
#define chSysLock()
/**
- * Leaves the ChobiOS/RT system mutual exclusion zone, the implementation is
+ * Leaves the ChibiOS/RT system mutual exclusion zone, the implementation is
* architecture dependent, on single core systems usually this function
* just enables the interrupts.
* @note The code in the system mutual exclusion zone must be as light and