1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #1885 from OlegHahm/thread_yield_higher_cleanup

core: thread_yield_higher cleanup
This commit is contained in:
Kaspar Schleiser 2014-10-30 23:22:27 +01:00
commit feb550f17a
4 changed files with 29 additions and 24 deletions

View File

@ -154,18 +154,9 @@ extern volatile int sched_num_threads;
extern volatile kernel_pid_t sched_active_pid;
/**
* @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()
* List of runqueues per priority level
*/
void thread_yield_higher(void);
extern clist_node_t *sched_runqueues[SCHED_PRIO_LEVELS];
#if SCHEDSTATISTICS
/**

View File

@ -124,6 +124,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.
*

View File

@ -45,7 +45,7 @@ volatile tcb_t *sched_active_thread;
volatile kernel_pid_t sched_active_pid = KERNEL_PID_UNDEF;
static clist_node_t *sched_runqueues[SCHED_PRIO_LEVELS];
clist_node_t *sched_runqueues[SCHED_PRIO_LEVELS];
static uint32_t runqueue_bitcache = 0;
#if SCHEDSTATISTICS
@ -175,15 +175,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();
}

View File

@ -91,6 +91,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)
{