aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-08-20 07:15:55 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-08-20 07:15:55 +0000
commitfef1911a8f6329ad97e4112965e004d21bffef73 (patch)
treea8916d9bb840aa83cd83606c676da97046401d1f /os
parent4e26a3b42cb49974f63d1b8727d7b1d1830c9c81 (diff)
downloadChibiOS-fef1911a8f6329ad97e4112965e004d21bffef73.tar.gz
ChibiOS-fef1911a8f6329ad97e4112965e004d21bffef73.tar.bz2
ChibiOS-fef1911a8f6329ad97e4112965e004d21bffef73.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2134 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/kernel/include/chsys.h13
-rw-r--r--os/kernel/include/chthreads.h9
-rw-r--r--os/kernel/src/chsys.c8
3 files changed, 26 insertions, 4 deletions
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h
index 5759d0cca..ae013d7c7 100644
--- a/os/kernel/include/chsys.h
+++ b/os/kernel/include/chsys.h
@@ -29,6 +29,16 @@
#define _CHSYS_H_
/**
+ * @brief Returns a pointer to the idle thread.
+ * @note The reference counter of the idle thread is not incremented but
+ * it is not strictly required being the idle thread a static
+ * object.
+ *
+ * @return Pointer to the idle thread,
+ */
+#define chSysGetIdleThread() ((Thread *)_idle_thread_wa)
+
+/**
* @brief Halts the system.
* @details This function is invoked by the operating system when an
* unrecoverable error is detected, as example because a programming
@@ -168,9 +178,12 @@
*/
#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
+extern WORKING_AREA(_idle_thread_wa, IDLE_THREAD_STACK_SIZE);
+
#ifdef __cplusplus
extern "C" {
#endif
+ void _idle_thread(void *p);
void chSysInit(void);
void chSysTimerHandlerI(void);
#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h
index 9eeff8666..1e659b768 100644
--- a/os/kernel/include/chthreads.h
+++ b/os/kernel/include/chthreads.h
@@ -251,6 +251,15 @@ extern "C" {
#define chThdGetPriority() (currp->p_prio)
/**
+ * @brief Returns the number of ticks consumed by the specified thread.
+ * @note This function is only available when the
+ * @p CH_DBG_THREADS_PROFILING configuration option is enabled.
+ *
+ * @param[in] tp the pointer to the thread
+ */
+#define chThdGetTicks(tp) ((tp)->p_time)
+
+/**
* @brief Returns the pointer to the @p Thread local storage area, if any.
*/
#define chThdLS() (void *)(currp + 1)
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c
index 1a66c8e98..80d037dd6 100644
--- a/os/kernel/src/chsys.c
+++ b/os/kernel/src/chsys.c
@@ -34,7 +34,7 @@
#include "ch.h"
-static WORKING_AREA(idle_thread_wa, IDLE_THREAD_STACK_SIZE);
+WORKING_AREA(_idle_thread_wa, IDLE_THREAD_STACK_SIZE);
/**
* @brief This function implements the idle thread infinite loop.
@@ -46,7 +46,7 @@ static WORKING_AREA(idle_thread_wa, IDLE_THREAD_STACK_SIZE);
*
* @param[in] p the thread parameter, unused in this scenario
*/
-static void idle_thread(void *p) {
+void _idle_thread(void *p) {
(void)p;
while (TRUE) {
@@ -87,8 +87,8 @@ void chSysInit(void) {
/* This thread has the lowest priority in the system, its role is just to
serve interrupts in its context while keeping the lowest energy saving
mode compatible with the system status.*/
- chThdCreateStatic(idle_thread_wa, sizeof(idle_thread_wa), IDLEPRIO,
- (tfunc_t)idle_thread, NULL);
+ chThdCreateStatic(idle_thread_wa, sizeof(_idle_thread_wa), IDLEPRIO,
+ (tfunc_t)_idle_thread, NULL);
}
/**