kernel: never do sched() in unlock() when not in "Running" state.

Some callers of unlock change the process state
(such as qlock()) which means they are committed
to calling sched() anyway, so no ned to call it
internally.
This commit is contained in:
cinap_lenrek 2024-01-05 01:58:37 +00:00
parent 381da3192f
commit 39321d74d8

View file

@ -204,13 +204,13 @@ unlock(Lock *l)
coherence();
l->key = 0;
if(up && --up->nlocks == 0 && up->delaysched && islo()){
/*
* Call sched if the need arose while locks were held
* But, don't do it from interrupt routines, hence the islo() test
*/
/*
* Call sched if the need arose while locks were held
* But, don't do it from interrupt routines, hence the islo() test
*/
if(up && --up->nlocks == 0)
if(up->state == Running && up->delaysched && islo())
sched();
}
}
uintptr ilockpcs[0x100] = { [0xff] = 1 };