kernel/arch: inspect prio/sched_locked together for preemptibility
These two fields in the thread structure control the preemptibility of a thread. sched_locked is decremented when the scheduler gets locked, which means that the scheduler is locked for values 0xff to 0x01, since it can be locked recursively. A thread is coop if its priority is negative, thus if the prio field value is 0x80 to 0xff when looked at as an unsigned value. By putting them end-to-end, this means that a thread is non-preemptible if the bundled value is greater than or equal to 0x0080. This is the only thing the interrupt exit code has to check to decide to try a reschedule or not. Change-Id: I902d36c14859d0d7a951a6aa1bea164613821aca Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
f955476559
commit
168695c7ef
10 changed files with 80 additions and 77 deletions
|
@ -84,21 +84,14 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, _ExcExit)
|
|||
ldr r0, =_kernel
|
||||
|
||||
ldr r1, [r0, #_kernel_offset_to_current]
|
||||
#ifdef CONFIG_CPU_CORTEX_M0_M0PLUS
|
||||
movs r3, #_thread_offset_to_prio
|
||||
ldrsb r2, [r1, r3]
|
||||
#else
|
||||
ldrsb r2, [r1, #_thread_offset_to_prio]
|
||||
#endif
|
||||
ldrb r3, [r1, #_thread_offset_to_sched_locked]
|
||||
|
||||
/* coop thread ? do not schedule */
|
||||
cmp r2, #0
|
||||
blt _EXIT_EXC
|
||||
|
||||
/* scheduler locked ? do not schedule */
|
||||
cmp r3, #0
|
||||
bne _EXIT_EXC
|
||||
/*
|
||||
* Non-preemptible thread ? Do not schedule (see explanation of
|
||||
* preempt field in kernel_struct.h).
|
||||
*/
|
||||
ldrh r2, [r1, #_thread_offset_to_preempt]
|
||||
cmp r2, #_PREEMPT_THRESHOLD
|
||||
bhi _EXIT_EXC
|
||||
|
||||
ldr r0, [r0, _kernel_offset_to_ready_q_cache]
|
||||
cmp r0, r1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue