Browse Source
Fixes #1708. Currently involuntary preemption causes the current thread not only to yield for a higher prioritized thread, but all other threads of its own priority class, too. This PR adds the function `thread_yield_higher()`, which will yield the current thread in favor of higher prioritized functions, but not for threads of its own priority class. Boards now need to implement `thread_yield_higher()` instead of `thread_yield()`, but `COREIF_NG` boards are not affected in any way. `thread_yield()` retains its old meaning: yield for every thread that has the same or a higher priority. This PR does not touch the occurrences of `thread_yield()` in the periph drivers, because the author of this PR did not look into the logic of the various driver implementations.dev/timer

18 changed files with 113 additions and 28 deletions
@ -0,0 +1,4 @@
|
||||
APPLICATION = sched_testing
|
||||
include ../Makefile.tests_common |
||||
|
||||
include $(RIOTBASE)/Makefile.include |
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Oliver Hahm <oliver.hahm@inria.fr> |
||||
* |
||||
* This file is subject to the terms and conditions of the GNU Lesser |
||||
* General Public License v2.1. See the file LICENSE in the top level |
||||
* directory for more details. |
||||
*/ |
||||
|
||||
/**
|
||||
* @ingroup tests |
||||
* @{ |
||||
* @file |
||||
* @brief Test thread_yield() |
||||
* @author Oliver Hahm <oliver.hahm@inria.fr> |
||||
* @author René Kijewski <rene.kijewski@fu-berlin.de> |
||||
* @} |
||||
*/ |
||||
|
||||
#include <stdio.h> |
||||
#include "thread.h" |
||||
|
||||
char snd_thread_stack[KERNEL_CONF_STACKSIZE_MAIN]; |
||||
|
||||
void *snd_thread(void *unused) |
||||
{ |
||||
(void) unused; |
||||
puts("snd_thread running"); |
||||
return NULL; |
||||
} |
||||
|
||||
int main(void) |
||||
{ |
||||
puts("The output should be: yield 1, snd_thread running, yield 2, done"); |
||||
puts("----------------------------------------------------------------"); |
||||
|
||||
thread_create(snd_thread_stack, sizeof(snd_thread_stack), PRIORITY_MAIN, |
||||
CREATE_WOUT_YIELD, snd_thread, NULL, "snd"); |
||||
|
||||
puts("yield 1"); |
||||
thread_yield(); |
||||
puts("yield 2"); |
||||
thread_yield(); |
||||
puts("done"); |
||||
|
||||
return 0; |
||||
} |
Loading…
Reference in new issue