diff --git a/arch/arc/core/thread.c b/arch/arc/core/thread.c index e66c6108aed..3ce8f0f5c09 100644 --- a/arch/arc/core/thread.c +++ b/arch/arc/core/thread.c @@ -42,38 +42,23 @@ struct init_stack_frame { tNANO _nanokernel = {0}; -#if defined(CONFIG_THREAD_MONITOR) -#define THREAD_MONITOR_INIT(tcs) thread_monitor_init(tcs) -#else -#define THREAD_MONITOR_INIT(tcs) \ - do {/* do nothing */ \ - } while ((0)) -#endif - #if defined(CONFIG_THREAD_MONITOR) /* - * @brief Initialize thread monitoring support - * - * Currently only inserts the new thread in the list of active threads. - * - * @return N/A + * Add a thread to the kernel's list of active threads. */ - static ALWAYS_INLINE void thread_monitor_init(struct tcs *tcs) { unsigned int key; - /* - * Add the newly initialized thread to head of the list of threads. This - * singly linked list of threads maintains ALL the threads in the system: - * both tasks and fibers regardless of whether they are runnable. - */ - key = irq_lock(); tcs->next_thread = _nanokernel.threads; _nanokernel.threads = tcs; irq_unlock(key); } +#else +#define thread_monitor_init(tcs) \ + do {/* do nothing */ \ + } while ((0)) #endif /* CONFIG_THREAD_MONITOR */ /* @@ -187,5 +172,5 @@ void _new_thread(char *pStackMem, unsigned stackSize, /* initial values in all other registers/TCS entries are irrelevant */ - THREAD_MONITOR_INIT(tcs); + thread_monitor_init(tcs); } diff --git a/arch/arm/core/thread.c b/arch/arm/core/thread.c index d70df235871..3f07b99eda1 100644 --- a/arch/arm/core/thread.c +++ b/arch/arm/core/thread.c @@ -34,40 +34,22 @@ tNANO _nanokernel = {0}; #if defined(CONFIG_THREAD_MONITOR) -#define THREAD_MONITOR_INIT(tcs) _thread_monitor_init(tcs) -#else -#define THREAD_MONITOR_INIT(tcs) \ - do {/* do nothing */ \ - } while ((0)) -#endif - -#if defined(CONFIG_THREAD_MONITOR) -/** - * - * @brief Initialize thread monitoring support - * - * Currently only inserts the new thread in the list of active threads. - * - * @return N/A +/* + * Add a thread to the kernel's list of active threads. */ - -static ALWAYS_INLINE void _thread_monitor_init(struct tcs *tcs /* thread */ - ) +static ALWAYS_INLINE void thread_monitor_init(struct tcs *tcs) { unsigned int key; - /* - * Add the newly initialized thread to head of the list of threads. - * This singly linked list of threads maintains ALL the threads in the - * system: - * both tasks and fibers regardless of whether they are runnable. - */ - key = irq_lock(); tcs->next_thread = _nanokernel.threads; _nanokernel.threads = tcs; irq_unlock(key); } +#else +#define thread_monitor_init(tcs) \ + do {/* do nothing */ \ + } while ((0)) #endif /* CONFIG_THREAD_MONITOR */ /** @@ -171,5 +153,5 @@ void _new_thread(char *pStackMem, unsigned stackSize, /* initial values in all other registers/TCS entries are irrelevant */ - THREAD_MONITOR_INIT(tcs); + thread_monitor_init(tcs); } diff --git a/arch/nios2/core/thread.c b/arch/nios2/core/thread.c index ac4568181d0..1eeaa2d74ce 100644 --- a/arch/nios2/core/thread.c +++ b/arch/nios2/core/thread.c @@ -21,38 +21,23 @@ tNANO _nanokernel = {0}; -#if defined(CONFIG_THREAD_MONITOR) -#define THREAD_MONITOR_INIT(tcs) thread_monitor_init(tcs) -#else -#define THREAD_MONITOR_INIT(tcs) \ - do {/* do nothing */ \ - } while ((0)) -#endif - #if defined(CONFIG_THREAD_MONITOR) /* - * @brief Initialize thread monitoring support - * - * Currently only inserts the new thread in the list of active threads. - * - * @return N/A + * Add a thread to the kernel's list of active threads. */ - static ALWAYS_INLINE void thread_monitor_init(struct tcs *tcs) { unsigned int key; - /* - * Add the newly initialized thread to head of the list of threads. This - * singly linked list of threads maintains ALL the threads in the system: - * both tasks and fibers regardless of whether they are runnable. - */ - key = irq_lock(); tcs->next_thread = _nanokernel.threads; _nanokernel.threads = tcs; irq_unlock(key); } +#else +#define thread_monitor_init(tcs) \ + do {/* do nothing */ \ + } while ((0)) #endif /* CONFIG_THREAD_MONITOR */ /* forward declaration to asm function to adjust setup the arguments @@ -131,5 +116,5 @@ void _new_thread(char *stack_memory, unsigned stack_size, _nano_timeout_tcs_init(tcs); #endif - THREAD_MONITOR_INIT(tcs); + thread_monitor_init(tcs); } diff --git a/arch/x86/core/thread.c b/arch/x86/core/thread.c index 8e25660182e..f03e457e629 100644 --- a/arch/x86/core/thread.c +++ b/arch/x86/core/thread.c @@ -49,6 +49,25 @@ void _thread_entry_wrapper(_thread_entry_t, void *, void *, void *); #endif +#if defined(CONFIG_THREAD_MONITOR) +/* + * Add a thread to the kernel's list of active threads. + */ +static ALWAYS_INLINE void thread_monitor_init(struct tcs *tcs) +{ + unsigned int key; + + key = irq_lock(); + tcs->next_thread = _nanokernel.threads; + _nanokernel.threads = tcs; + irq_unlock(key); +} +#else +#define thread_monitor_init(tcs) \ + do {/* do nothing */ \ + } while ((0)) +#endif /* CONFIG_THREAD_MONITOR */ + /** * * @brief Initialize a new execution thread @@ -207,23 +226,7 @@ static void _new_thread_internal(char *pStackMem, unsigned stackSize, PRINTK("\nstruct tcs * = 0x%x", tcs); -#if defined(CONFIG_THREAD_MONITOR) - { - unsigned int imask; - - /* - * Add the newly initialized thread to head of the list of threads. - * This singly linked list of threads maintains ALL the threads in the - * system: both tasks and fibers regardless of whether they are - * runnable. - */ - - imask = irq_lock(); - tcs->next_thread = _nanokernel.threads; - _nanokernel.threads = tcs; - irq_unlock(imask); - } -#endif /* CONFIG_THREAD_MONITOR */ + thread_monitor_init(tcs); _nano_timeout_tcs_init(tcs); }