kernel: rename thread states symbols

They are not part of the API, so rename from K_<state> to
_THREAD_<state>.

Change-Id: Iaebb7d3083b80b9769bee5616e0f96ed2abc5c56
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
This commit is contained in:
Benjamin Walsh 2017-01-22 11:41:59 -05:00 committed by Anas Nashif
parent 3f3f4d94d5
commit a8978aba8f
10 changed files with 38 additions and 36 deletions

View file

@ -113,7 +113,7 @@ void _new_thread(char *pStackMem, size_t stackSize,
pInitCtx->status32 = _ARC_V2_STATUS32_E(_ARC_V2_DEF_IRQ_LEVEL);
#endif
_init_thread_base(&thread->base, priority, K_PRESTART, options);
_init_thread_base(&thread->base, priority, _THREAD_PRESTART, options);
/* static threads overwrite them afterwards with real values */
thread->init_data = NULL;

View file

@ -100,7 +100,7 @@ void _new_thread(char *pStackMem, size_t stackSize,
pInitCtx->xpsr =
0x01000000UL; /* clear all, thumb bit is 1, even if RO */
_init_thread_base(&tcs->base, priority, K_PRESTART, options);
_init_thread_base(&tcs->base, priority, _THREAD_PRESTART, options);
/* static threads overwrite it afterwards with real value */
tcs->init_data = NULL;

View file

@ -76,7 +76,7 @@ void _new_thread(char *stack_memory, size_t stack_size,
/* Initialize various struct k_thread members */
thread = (struct k_thread *)stack_memory;
_init_thread_base(&thread->base, priority, K_PRESTART, options);
_init_thread_base(&thread->base, priority, _THREAD_PRESTART, options);
/* static threads overwrite it afterwards with real value */
thread->init_data = NULL;

View file

@ -86,7 +86,7 @@ void _new_thread(char *stack_memory, size_t stack_size,
/* Initialize various struct k_thread members */
thread = (struct k_thread *)stack_memory;
_init_thread_base(&thread->base, priority, K_PRESTART, options);
_init_thread_base(&thread->base, priority, _THREAD_PRESTART, options);
/* static threads overwrite it afterwards with real value */
thread->init_data = NULL;

View file

@ -77,7 +77,7 @@ static void _new_thread_internal(char *pStackMem, unsigned stackSize,
thread->arch.excNestCount = 0;
#endif /* CONFIG_FP_SHARING || CONFIG_GDB_INFO */
_init_thread_base(&thread->base, priority, K_PRESTART, options);
_init_thread_base(&thread->base, priority, _THREAD_PRESTART, options);
/* static threads overwrite it afterwards with real value */
thread->init_data = NULL;

View file

@ -28,19 +28,19 @@
#define K_ESSENTIAL (1 << 0)
/* Thread is waiting on an object */
#define K_PENDING (1 << 1)
#define _THREAD_PENDING (1 << 1)
/* Thread has not yet started */
#define K_PRESTART (1 << 2)
#define _THREAD_PRESTART (1 << 2)
/* Thread has terminated */
#define K_DEAD (1 << 3)
#define _THREAD_DEAD (1 << 3)
/* Thread is suspended */
#define K_SUSPENDED (1 << 4)
#define _THREAD_SUSPENDED (1 << 4)
/* Not a real thread */
#define K_DUMMY (1 << 5)
#define _THREAD_DUMMY (1 << 5)
/* end - states */

View file

@ -274,13 +274,13 @@ static inline void _reset_thread_states(struct k_thread *thread,
/* mark a thread as being suspended */
static inline void _mark_thread_as_suspended(struct k_thread *thread)
{
thread->base.thread_state |= K_SUSPENDED;
thread->base.thread_state |= _THREAD_SUSPENDED;
}
/* mark a thread as not being suspended */
static inline void _mark_thread_as_not_suspended(struct k_thread *thread)
{
thread->base.thread_state &= ~K_SUSPENDED;
thread->base.thread_state &= ~_THREAD_SUSPENDED;
}
static ALWAYS_INLINE int _is_thread_timeout_expired(struct k_thread *thread)
@ -304,14 +304,15 @@ static inline int _is_thread_timeout_active(struct k_thread *thread)
static inline int _has_thread_started(struct k_thread *thread)
{
return !(thread->base.thread_state & K_PRESTART);
return !(thread->base.thread_state & _THREAD_PRESTART);
}
static inline int _is_thread_prevented_from_running(struct k_thread *thread)
{
return thread->base.thread_state & (K_PENDING | K_PRESTART |
K_DEAD | K_DUMMY |
K_SUSPENDED);
uint8_t state = thread->base.thread_state;
return state & (_THREAD_PENDING | _THREAD_PRESTART | _THREAD_DEAD |
_THREAD_DUMMY | _THREAD_SUSPENDED);
}
@ -325,19 +326,19 @@ static inline int _is_thread_ready(struct k_thread *thread)
/* mark a thread as pending in its TCS */
static inline void _mark_thread_as_pending(struct k_thread *thread)
{
thread->base.thread_state |= K_PENDING;
thread->base.thread_state |= _THREAD_PENDING;
}
/* mark a thread as not pending in its TCS */
static inline void _mark_thread_as_not_pending(struct k_thread *thread)
{
thread->base.thread_state &= ~K_PENDING;
thread->base.thread_state &= ~_THREAD_PENDING;
}
/* check if a thread is pending */
static inline int _is_thread_pending(struct k_thread *thread)
{
return !!(thread->base.thread_state & K_PENDING);
return !!(thread->base.thread_state & _THREAD_PENDING);
}
/**
@ -347,7 +348,7 @@ static inline int _is_thread_pending(struct k_thread *thread)
*/
static inline void _mark_thread_as_started(struct k_thread *thread)
{
thread->base.thread_state &= ~K_PRESTART;
thread->base.thread_state &= ~_THREAD_PRESTART;
}
/*
@ -385,7 +386,7 @@ static inline void _ready_thread(struct k_thread *thread)
*/
static inline void _mark_thread_as_dead(struct k_thread *thread)
{
thread->base.thread_state |= K_DEAD;
thread->base.thread_state |= _THREAD_DEAD;
}
/*
@ -454,7 +455,7 @@ static inline struct k_thread *_unpend_first_thread(_wait_q_t *wait_q)
/* must be called with interrupts locked */
static inline void _unpend_thread(struct k_thread *thread)
{
__ASSERT(thread->base.thread_state & K_PENDING, "");
__ASSERT(thread->base.thread_state & _THREAD_PENDING, "");
sys_dlist_remove(&thread->base.k_q_node);
_mark_thread_as_not_pending(thread);

View file

@ -67,9 +67,9 @@ static int init_mbox_module(struct device *dev)
* Create pool of asynchronous message descriptors.
*
* A dummy thread requires minimal initialization, since it never gets
* to execute. The K_DUMMY flag is sufficient to distinguish a dummy
* thread from a real one. The threads are *not* added to the kernel's
* list of known threads.
* to execute. The _THREAD_DUMMY flag is sufficient to distinguish a
* dummy thread from a real one. The threads are *not* added to the
* kernel's list of known threads.
*
* Once initialized, the address of each descriptor is added to a stack
* that governs access to them.
@ -78,7 +78,7 @@ static int init_mbox_module(struct device *dev)
int i;
for (i = 0; i < CONFIG_NUM_MBOX_ASYNC_MSGS; i++) {
_init_thread_base(&async_msg[i].thread, 0, K_DUMMY, 0);
_init_thread_base(&async_msg[i].thread, 0, _THREAD_DUMMY, 0);
k_stack_push(&async_msg_free, (uint32_t)&async_msg[i]);
}
#endif /* CONFIG_NUM_MBOX_ASYNC_MSGS > 0 */
@ -201,7 +201,7 @@ static void _mbox_message_dispose(struct k_mbox_msg *rx_msg)
* asynchronous send: free asynchronous message descriptor +
* dummy thread pair, then give semaphore (if needed)
*/
if (sending_thread->base.thread_state & K_DUMMY) {
if (sending_thread->base.thread_state & _THREAD_DUMMY) {
struct k_sem *async_sem = tx_msg->_async_sem;
_mbox_async_free((struct k_mbox_async *)sending_thread);
@ -276,7 +276,7 @@ static int _mbox_message_put(struct k_mbox *mbox, struct k_mbox_msg *tx_msg,
* note: dummy sending thread sits (unqueued)
* until the receiver consumes the message
*/
if (sending_thread->base.thread_state & K_DUMMY) {
if (sending_thread->base.thread_state & _THREAD_DUMMY) {
_reschedule_threads(key);
return 0;
}
@ -300,7 +300,7 @@ static int _mbox_message_put(struct k_mbox *mbox, struct k_mbox_msg *tx_msg,
#if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0)
/* asynchronous send: dummy thread waits on tx queue for receiver */
if (sending_thread->base.thread_state & K_DUMMY) {
if (sending_thread->base.thread_state & _THREAD_DUMMY) {
_pend_thread(sending_thread, &mbox->tx_msg_queue, K_FOREVER);
irq_unlock(key);
return 0;

View file

@ -92,16 +92,16 @@ static int init_pipes_module(struct device *dev)
* Create pool of asynchronous pipe message descriptors.
*
* A dummy thread requires minimal initialization, since it never gets
* to execute. The K_DUMMY flag is sufficient to distinguish a dummy
* thread from a real one. The threads are *not* added to the kernel's
* list of known threads.
* to execute. The _THREAD_DUMMY flag is sufficient to distinguish a
* dummy thread from a real one. The threads are *not* added to the
* kernel's list of known threads.
*
* Once initialized, the address of each descriptor is added to a stack
* that governs access to them.
*/
for (int i = 0; i < CONFIG_NUM_PIPE_ASYNC_MSGS; i++) {
async_msg[i].thread.thread_state = K_DUMMY;
async_msg[i].thread.thread_state = _THREAD_DUMMY;
async_msg[i].thread.swap_data = &async_msg[i].desc;
k_stack_push(&pipe_async_msgs, (uint32_t)&async_msg[i]);
}
@ -367,7 +367,7 @@ static void _pipe_thread_ready(struct k_thread *thread)
unsigned int key;
#if (CONFIG_NUM_PIPE_ASYNC_MSGS > 0)
if (thread->base.thread_state & K_DUMMY) {
if (thread->base.thread_state & _THREAD_DUMMY) {
_pipe_async_finish((struct k_pipe_async *)thread);
return;
}

View file

@ -114,7 +114,8 @@ int k_sem_group_take(struct k_sem *sem_array[], struct k_sem **sem,
for (int i = 0; i < num; i++) {
_init_thread_base(&wait_objects[i].dummy, priority, K_DUMMY, 0);
_init_thread_base(&wait_objects[i].dummy, priority,
_THREAD_DUMMY, 0);
sys_dlist_append(&list, &wait_objects[i].desc.semg_node);
wait_objects[i].desc.thread = _current;
@ -160,7 +161,7 @@ static int handle_sem_group(struct k_sem *sem, struct k_thread *thread)
sys_dnode_t *node;
sys_dnode_t *next;
if (!(thread->base.thread_state & K_DUMMY)) {
if (!(thread->base.thread_state & _THREAD_DUMMY)) {
/*
* The awakened thread is a real thread and thus was not
* involved in a semaphore group operation.