kernel: refactor thread_monitor_init into common code
We do the same thing on all arch's right now for thread_monitor_init so lets put it in a common place. This also should fix an issue on xtensa when thread monitor can be enabled (reference to _nanokernel.threads). Change-Id: If2f26c1578aa1f18565a530de4880ae7bd5a0da2 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
b8823c4efd
commit
96ee45df8d
7 changed files with 20 additions and 131 deletions
|
@ -29,25 +29,6 @@ struct init_stack_frame {
|
||||||
u32_t r0;
|
u32_t r0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CONFIG_THREAD_MONITOR)
|
|
||||||
/*
|
|
||||||
* Add a thread to the kernel's list of active threads.
|
|
||||||
*/
|
|
||||||
static ALWAYS_INLINE void thread_monitor_init(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
unsigned int key;
|
|
||||||
|
|
||||||
key = irq_lock();
|
|
||||||
thread->next_thread = _kernel.threads;
|
|
||||||
_kernel.threads = thread;
|
|
||||||
irq_unlock(key);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define thread_monitor_init(thread) \
|
|
||||||
do {/* do nothing */ \
|
|
||||||
} while ((0))
|
|
||||||
#endif /* CONFIG_THREAD_MONITOR */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Initialize a new thread from its stack space
|
* @brief Initialize a new thread from its stack space
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,25 +19,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif /* CONFIG_INIT_STACKS */
|
#endif /* CONFIG_INIT_STACKS */
|
||||||
|
|
||||||
#if defined(CONFIG_THREAD_MONITOR)
|
|
||||||
/*
|
|
||||||
* Add a thread to the kernel's list of active threads.
|
|
||||||
*/
|
|
||||||
static ALWAYS_INLINE void thread_monitor_init(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
unsigned int key;
|
|
||||||
|
|
||||||
key = irq_lock();
|
|
||||||
thread->next_thread = _kernel.threads;
|
|
||||||
_kernel.threads = thread;
|
|
||||||
irq_unlock(key);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define thread_monitor_init(thread) \
|
|
||||||
do {/* do nothing */ \
|
|
||||||
} while ((0))
|
|
||||||
#endif /* CONFIG_THREAD_MONITOR */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Initialize a new thread from its stack space
|
* @brief Initialize a new thread from its stack space
|
||||||
|
|
|
@ -10,25 +10,6 @@
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(CONFIG_THREAD_MONITOR)
|
|
||||||
/*
|
|
||||||
* Add a thread to the kernel's list of active threads.
|
|
||||||
*/
|
|
||||||
static ALWAYS_INLINE void thread_monitor_init(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
unsigned int key;
|
|
||||||
|
|
||||||
key = irq_lock();
|
|
||||||
thread->next_thread = _kernel.threads;
|
|
||||||
_kernel.threads = thread;
|
|
||||||
irq_unlock(key);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define thread_monitor_init(thread) \
|
|
||||||
do {/* do nothing */ \
|
|
||||||
} while ((0))
|
|
||||||
#endif /* CONFIG_THREAD_MONITOR */
|
|
||||||
|
|
||||||
/* forward declaration to asm function to adjust setup the arguments
|
/* forward declaration to asm function to adjust setup the arguments
|
||||||
* to _thread_entry() since this arch puts the first four arguments
|
* to _thread_entry() since this arch puts the first four arguments
|
||||||
* in r4-r7 and not on the stack
|
* in r4-r7 and not on the stack
|
||||||
|
|
|
@ -10,25 +10,6 @@
|
||||||
#include <wait_q.h>
|
#include <wait_q.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(CONFIG_THREAD_MONITOR)
|
|
||||||
/*
|
|
||||||
* Add a thread to the kernel's list of active threads.
|
|
||||||
*/
|
|
||||||
static ALWAYS_INLINE void thread_monitor_init(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
unsigned int key;
|
|
||||||
|
|
||||||
key = irq_lock();
|
|
||||||
thread->next_thread = _kernel.threads;
|
|
||||||
_kernel.threads = thread;
|
|
||||||
irq_unlock(key);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define thread_monitor_init(thread) \
|
|
||||||
do {/* do nothing */ \
|
|
||||||
} while ((0))
|
|
||||||
#endif /* CONFIG_THREAD_MONITOR */
|
|
||||||
|
|
||||||
void _thread_entry_wrapper(_thread_entry_t thread,
|
void _thread_entry_wrapper(_thread_entry_t thread,
|
||||||
void *arg1,
|
void *arg1,
|
||||||
void *arg2,
|
void *arg2,
|
||||||
|
|
|
@ -29,25 +29,6 @@ void _thread_entry_wrapper(_thread_entry_t, void *,
|
||||||
void *, void *);
|
void *, void *);
|
||||||
#endif
|
#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 k_thread *thread)
|
|
||||||
{
|
|
||||||
unsigned int key;
|
|
||||||
|
|
||||||
key = irq_lock();
|
|
||||||
thread->next_thread = _kernel.threads;
|
|
||||||
_kernel.threads = thread;
|
|
||||||
irq_unlock(key);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define thread_monitor_init(thread) \
|
|
||||||
do {/* do nothing */ \
|
|
||||||
} while ((0))
|
|
||||||
#endif /* CONFIG_THREAD_MONITOR */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Initialize a new execution thread
|
* @brief Initialize a new execution thread
|
||||||
|
|
|
@ -15,41 +15,6 @@
|
||||||
|
|
||||||
extern void _xt_user_exit(void);
|
extern void _xt_user_exit(void);
|
||||||
|
|
||||||
#if defined(CONFIG_THREAD_MONITOR)
|
|
||||||
#define THREAD_MONITOR_INIT(thread) _thread_monitor_init(thread)
|
|
||||||
#else
|
|
||||||
#define THREAD_MONITOR_INIT(thread) \
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void _thread_monitor_init(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
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 regardless of whether they are runnable.
|
|
||||||
*/
|
|
||||||
|
|
||||||
key = irq_lock();
|
|
||||||
thread->next_thread = _nanokernel.threads;
|
|
||||||
_nanokernel.threads = thread;
|
|
||||||
irq_unlock(key);
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_THREAD_MONITOR */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Initialize a new thread from its stack space
|
* @brief Initialize a new thread from its stack space
|
||||||
*
|
*
|
||||||
|
@ -164,6 +129,6 @@ void _new_thread(char *pStack, size_t stackSize,
|
||||||
* irrelevant
|
* irrelevant
|
||||||
*/
|
*/
|
||||||
|
|
||||||
THREAD_MONITOR_INIT(thread);
|
thread_monitor_init(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,6 +268,25 @@ static ALWAYS_INLINE struct k_thread *_new_thread_init(char *pStack,
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_THREAD_MONITOR)
|
||||||
|
/*
|
||||||
|
* Add a thread to the kernel's list of active threads.
|
||||||
|
*/
|
||||||
|
static ALWAYS_INLINE void thread_monitor_init(struct k_thread *thread)
|
||||||
|
{
|
||||||
|
unsigned int key;
|
||||||
|
|
||||||
|
key = irq_lock();
|
||||||
|
thread->next_thread = _kernel.threads;
|
||||||
|
_kernel.threads = thread;
|
||||||
|
irq_unlock(key);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define thread_monitor_init(thread) \
|
||||||
|
do {/* do nothing */ \
|
||||||
|
} while ((0))
|
||||||
|
#endif /* CONFIG_THREAD_MONITOR */
|
||||||
|
|
||||||
#endif /* _ASMLANGUAGE */
|
#endif /* _ASMLANGUAGE */
|
||||||
|
|
||||||
#endif /* _kernel_structs__h_ */
|
#endif /* _kernel_structs__h_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue