TDF_NEEDRESCHED (was: Realtime thread priorities)
davidxu at freebsd.org
Wed Dec 29 08:22:24 UTC 2010
I think flag TDF_NEEDRESCHED should not be cleared by sched_switch() in
ULE or 4BSD, instead it should only be cleared by ast() in subr_trap.c.
The reason is that the flag indicates thread should reset its priority
and switch context at user boundary because its user mode priority is
lowered or there is higher priority thread wants to run.
Kernel needs to use this flag to reset its priority to td_user_pri
before a thread returns to user mode, in current code, if an interrupt
thread preempts a user thread, sched_switch() clears the flag for
preempted thread and then switches to preempting thread, this causes
preempted thread to forget resetting its current priority to td_user_pri
this becauses assemble language code doreti() can not find the flag,
and ast() is not called, the thread ends up running user mode code
at very high level priority. Fix me, if I am wrong.
More information about the freebsd-arch