Browse Source

core: move thread_yield*() to thread.[ch]

Although it might conceptionally rather belong to the scheduler, the
yield functions are prefixed with thread_ and thus, belong there.
dev/timer
Oleg Hahm 8 years ago
parent
commit
93ac114bc3
  1. 14
      core/include/sched.h
  2. 14
      core/include/thread.h
  3. 12
      core/sched.c
  4. 12
      core/thread.c

14
core/include/sched.h

@ -157,20 +157,6 @@ extern volatile kernel_pid_t sched_active_pid;
*/
extern clist_node_t *sched_runqueues[SCHED_PRIO_LEVELS];
/**
* @brief Lets current thread yield in favor of a higher prioritized thread.
*
* @details The current thread will resume operation immediately,
* if there is no other ready thread with a higher priority.
*
* Differently from thread_yield() the current thread will be scheduled next
* in its own priority class, i.e. it stays the first thread in its
* priority class.
*
* @see thread_yield()
*/
void thread_yield_higher(void);
#if SCHEDSTATISTICS
/**
* Scheduler statistics

14
core/include/thread.h

@ -134,6 +134,20 @@ void thread_sleep(void);
*/
void thread_yield(void);
/**
* @brief Lets current thread yield in favor of a higher prioritized thread.
*
* @details The current thread will resume operation immediately,
* if there is no other ready thread with a higher priority.
*
* Differently from thread_yield() the current thread will be scheduled next
* in its own priority class, i.e. it stays the first thread in its
* priority class.
*
* @see thread_yield()
*/
void thread_yield_higher(void);
/**
* @brief Wakes up a sleeping thread.
*

12
core/sched.c

@ -179,15 +179,3 @@ NORETURN void sched_task_exit(void)
sched_active_thread = NULL;
cpu_switch_context_exit();
}
void thread_yield(void)
{
unsigned old_state = disableIRQ();
tcb_t *me = (tcb_t *)sched_active_thread;
if (me->status >= STATUS_ON_RUNQUEUE) {
clist_advance(&sched_runqueues[me->priority]);
}
restoreIRQ(old_state);
thread_yield_higher();
}

12
core/thread.c

@ -89,6 +89,18 @@ int thread_wakeup(kernel_pid_t pid)
}
}
void thread_yield(void)
{
unsigned old_state = disableIRQ();
tcb_t *me = (tcb_t *)sched_active_thread;
if (me->status >= STATUS_ON_RUNQUEUE) {
clist_advance(&sched_runqueues[me->priority]);
}
restoreIRQ(old_state);
thread_yield_higher();
}
#ifdef DEVELHELP
uintptr_t thread_measure_stack_free(char *stack)
{

Loading…
Cancel
Save