mirror of
https://github.com/kelvinlawson/atomthreads.git
synced 2026-01-11 18:33:16 +01:00
Fix potential TCB loss
Always clear "suspended" flag in atomThreadSwitch(), even if new and old TCB are identical. Otherwise TCB could get lost during next task scheduling.
This commit is contained in:
@@ -332,6 +332,13 @@ void atomSched (uint8_t timer_tick)
|
|||||||
*/
|
*/
|
||||||
static void atomThreadSwitch(ATOM_TCB *old_tcb, ATOM_TCB *new_tcb)
|
static void atomThreadSwitch(ATOM_TCB *old_tcb, ATOM_TCB *new_tcb)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The context switch will shift execution to a different thread. The
|
||||||
|
* new thread is now ready to run so clear its suspend status in
|
||||||
|
* preparation for it waking up.
|
||||||
|
*/
|
||||||
|
new_tcb->suspended = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the new thread is actually the current one, in which
|
* Check if the new thread is actually the current one, in which
|
||||||
* case we don't need to do any context switch. This can happen
|
* case we don't need to do any context switch. This can happen
|
||||||
@@ -343,13 +350,6 @@ static void atomThreadSwitch(ATOM_TCB *old_tcb, ATOM_TCB *new_tcb)
|
|||||||
/* Set the new currently-running thread pointer */
|
/* Set the new currently-running thread pointer */
|
||||||
curr_tcb = new_tcb;
|
curr_tcb = new_tcb;
|
||||||
|
|
||||||
/**
|
|
||||||
* The context switch will shift execution to a different thread. The
|
|
||||||
* new thread is now ready to run so clear its suspend status in
|
|
||||||
* preparation for it waking up.
|
|
||||||
*/
|
|
||||||
new_tcb->suspended = FALSE;
|
|
||||||
|
|
||||||
/* Call the architecture-specific context switch */
|
/* Call the architecture-specific context switch */
|
||||||
archContextSwitch (old_tcb, new_tcb);
|
archContextSwitch (old_tcb, new_tcb);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user