kernel: fix race condition in sys_clock_announce()
Updates sys_clock_announce() such that the <announce_remaining> update calculation is done after the callback. This prevents another core from entering the timeout processing loop before the first core leaves it. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
3967911d3b
commit
3e2f30a7ef
1 changed files with 2 additions and 2 deletions
|
@ -250,7 +250,7 @@ void sys_clock_announce(int32_t ticks)
|
|||
* timeouts and confuse apps), just increment the tick count
|
||||
* and return.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_SMP) && announce_remaining != 0) {
|
||||
if (IS_ENABLED(CONFIG_SMP) && (announce_remaining != 0)) {
|
||||
announce_remaining += ticks;
|
||||
k_spin_unlock(&timeout_lock, key);
|
||||
return;
|
||||
|
@ -263,13 +263,13 @@ void sys_clock_announce(int32_t ticks)
|
|||
int dt = t->dticks;
|
||||
|
||||
curr_tick += dt;
|
||||
announce_remaining -= dt;
|
||||
t->dticks = 0;
|
||||
remove_timeout(t);
|
||||
|
||||
k_spin_unlock(&timeout_lock, key);
|
||||
t->fn(t);
|
||||
key = k_spin_lock(&timeout_lock);
|
||||
announce_remaining -= dt;
|
||||
}
|
||||
|
||||
if (first() != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue