mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #11509 from kaspar030/cleanup_core_thread
core/thread: unify thread_t variable naming
This commit is contained in:
commit
59a9ed4616
@ -40,15 +40,15 @@ volatile thread_t *thread_get(kernel_pid_t pid)
|
|||||||
|
|
||||||
int thread_getstatus(kernel_pid_t pid)
|
int thread_getstatus(kernel_pid_t pid)
|
||||||
{
|
{
|
||||||
volatile thread_t *t = thread_get(pid);
|
volatile thread_t *thread = thread_get(pid);
|
||||||
return t ? (int)t->status : (int)STATUS_NOT_FOUND;
|
return thread ? (int)thread->status : (int)STATUS_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *thread_getname(kernel_pid_t pid)
|
const char *thread_getname(kernel_pid_t pid)
|
||||||
{
|
{
|
||||||
#ifdef DEVELHELP
|
#ifdef DEVELHELP
|
||||||
volatile thread_t *t = thread_get(pid);
|
volatile thread_t *thread = thread_get(pid);
|
||||||
return t ? t->name : NULL;
|
return thread ? thread->name : NULL;
|
||||||
#else
|
#else
|
||||||
(void)pid;
|
(void)pid;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -73,18 +73,18 @@ int thread_wakeup(kernel_pid_t pid)
|
|||||||
|
|
||||||
unsigned old_state = irq_disable();
|
unsigned old_state = irq_disable();
|
||||||
|
|
||||||
thread_t *other_thread = (thread_t *) thread_get(pid);
|
thread_t *thread = (thread_t *) thread_get(pid);
|
||||||
|
|
||||||
if (!other_thread) {
|
if (!thread) {
|
||||||
DEBUG("thread_wakeup: Thread does not exist!\n");
|
DEBUG("thread_wakeup: Thread does not exist!\n");
|
||||||
}
|
}
|
||||||
else if (other_thread->status == STATUS_SLEEPING) {
|
else if (thread->status == STATUS_SLEEPING) {
|
||||||
DEBUG("thread_wakeup: Thread is sleeping.\n");
|
DEBUG("thread_wakeup: Thread is sleeping.\n");
|
||||||
|
|
||||||
sched_set_status(other_thread, STATUS_RUNNING);
|
sched_set_status(thread, STATUS_RUNNING);
|
||||||
|
|
||||||
irq_restore(old_state);
|
irq_restore(old_state);
|
||||||
sched_switch(other_thread->priority);
|
sched_switch(thread->priority);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
|
|||||||
DEBUG("thread_create: stacksize is too small!\n");
|
DEBUG("thread_create: stacksize is too small!\n");
|
||||||
}
|
}
|
||||||
/* allocate our thread control block at the top of our stackspace */
|
/* allocate our thread control block at the top of our stackspace */
|
||||||
thread_t *cb = (thread_t *) (stack + stacksize);
|
thread_t *thread = (thread_t *) (stack + stacksize);
|
||||||
|
|
||||||
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK)
|
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK)
|
||||||
if (flags & THREAD_CREATE_STACKTEST) {
|
if (flags & THREAD_CREATE_STACKTEST) {
|
||||||
@ -209,41 +209,41 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags,
|
|||||||
return -EOVERFLOW;
|
return -EOVERFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_threads[pid] = cb;
|
sched_threads[pid] = thread;
|
||||||
|
|
||||||
cb->pid = pid;
|
thread->pid = pid;
|
||||||
cb->sp = thread_stack_init(function, arg, stack, stacksize);
|
thread->sp = thread_stack_init(function, arg, stack, stacksize);
|
||||||
|
|
||||||
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD)
|
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD)
|
||||||
cb->stack_start = stack;
|
thread->stack_start = stack;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEVELHELP
|
#ifdef DEVELHELP
|
||||||
cb->stack_size = total_stacksize;
|
thread->stack_size = total_stacksize;
|
||||||
cb->name = name;
|
thread->name = name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cb->priority = priority;
|
thread->priority = priority;
|
||||||
cb->status = STATUS_STOPPED;
|
thread->status = STATUS_STOPPED;
|
||||||
|
|
||||||
cb->rq_entry.next = NULL;
|
thread->rq_entry.next = NULL;
|
||||||
|
|
||||||
#ifdef MODULE_CORE_MSG
|
#ifdef MODULE_CORE_MSG
|
||||||
cb->wait_data = NULL;
|
thread->wait_data = NULL;
|
||||||
cb->msg_waiters.next = NULL;
|
thread->msg_waiters.next = NULL;
|
||||||
cib_init(&(cb->msg_queue), 0);
|
cib_init(&(thread->msg_queue), 0);
|
||||||
cb->msg_array = NULL;
|
thread->msg_array = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sched_num_threads++;
|
sched_num_threads++;
|
||||||
|
|
||||||
DEBUG("Created thread %s. PID: %" PRIkernel_pid ". Priority: %u.\n", name, cb->pid, priority);
|
DEBUG("Created thread %s. PID: %" PRIkernel_pid ". Priority: %u.\n", name, thread->pid, priority);
|
||||||
|
|
||||||
if (flags & THREAD_CREATE_SLEEPING) {
|
if (flags & THREAD_CREATE_SLEEPING) {
|
||||||
sched_set_status(cb, STATUS_SLEEPING);
|
sched_set_status(thread, STATUS_SLEEPING);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sched_set_status(cb, STATUS_PENDING);
|
sched_set_status(thread, STATUS_PENDING);
|
||||||
|
|
||||||
if (!(flags & THREAD_CREATE_WOUT_YIELD)) {
|
if (!(flags & THREAD_CREATE_WOUT_YIELD)) {
|
||||||
irq_restore(state);
|
irq_restore(state);
|
||||||
|
Loading…
Reference in New Issue
Block a user