From fef1911a8f6329ad97e4112965e004d21bffef73 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 20 Aug 2010 07:15:55 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2134 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 13 +++++++++++++ os/kernel/include/chthreads.h | 9 +++++++++ os/kernel/src/chsys.c | 8 ++++---- 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'os/kernel') 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 @@ -28,6 +28,16 @@ #ifndef _CHSYS_H_ #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 @@ -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 @@ -250,6 +250,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. */ 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); } /** -- cgit v1.2.3