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.
PR #1000 overlooked to rename `runqueues` into `sched_runqueues` in
`sched.h`. This shows that the variable is not used outside of
`sched.c`.
As the list should not be accessed outside of the scheduler, so it
can be `static`.
sched_switch() is called by some library functions when a call unblocks
another thread. Then it needs to be tested if the current thread should
be preempted for the newly runnable thread.
A non-volutarily yield should only happen if the unblocked thread has a
_higher_ priority than the current thread. The current implementation,
which tests if the other thread has the same or a higher priority, does
not fit the documentation.
Right now the core component `clist` is a generic cyclic doubly-linked list.
In the core it is used in `tcb_t::rq_entry`.
Further it is used `net_if.c`.
This commit removes the member `clist_node_t::data` which stored the
pointer to the `tcb_t` instance of which the clist is already a member.
The needless member added `sizeof (int)` bytes to every instance of
`tcb_t`.
In `net_if.c` the clist was used in a type-punned way, so that the
change won't affect it.
In many places we needlessly use `sched_active_thread->pid` whilst we
already have `sched_active_pid` with the same value, and one less
indirection.
`thread_getpid()` is made `static inline` so that there is no penalty in
using this function over accessing `sched_active_pid` directly.
Instead of using differing integer types use kernel_pid_t for process
identifier. This type is introduced in a new header file to avoid
circular dependencies.
pid and tcb_t were compared instead of pid and pid
SCHEDSTATISTICS:
- reduce hwtimer_now calls
- dont use thread_last_pid anymore
- increase readability
- remove stray spaces
- remove TODOs:
- MODULE_HWTIMER is not a module anymore
- checking for NULL is necessary, at least without API changes:
`sched_task_exit` sets `sched_active_thread` to `NULL`, then exits,
afterwards `cpu_switch_context_exit` calls `sched_run`
The scheduling gets activated by `kernel_init()` calling
`cpu_switch_context_exit()`. Before this `sched_run()` won't be called.
When it gets called, at least the main thread and the idle thread are
spawned. The idle thread won't die / get killed. So there always is at
least one thread in `runqueue_bitcache`.
Closes#19.
- Included a collection of cpu-dependent headers in core/include/arch
- Extracted all interfaces that need to be implemented for a cpu
- Created a mapping between those interfaces and the old ones
- added flag for disabling arch interface
- added missing state to lpm_arch interface
- added arch interface for reboot
- fixed newline issues that were pointed out
- documentation fixes to cpu-core interface
and added `UNREACHABLE();` to hint the compiler unreachable lines
added right signature for first parameter of `thread_stack_init()`
added `UNREACHABLE();` macro to `cpu/lpc1768/atom.c` and `cpu/msp430-common/cpu.c`