4.4BSD timeslice management
John Baldwin
jhb at freebsd.org
Tue Oct 11 12:34:16 UTC 2011
On Wednesday, October 05, 2011 12:54:57 pm Riccardo Cattaneo wrote:
> Hello,
> I'm looking into the code of 4.4BSD scheduler (and related files) of FreeBSD
version 7.2-RELEASE on an amd64 machine in order to understand how to manage
time slices. I'm trying to dynamically change the length of the time slice on
a thread by thread basis to "give more priority" or "less priority" to
threads.
> In function sched_clock (sched_4bsd.c) I found a piece of code in which
thread's flags are added with TDF_NEEDRESCHED when the time slice (quantum)
expires but I failed to notice any point in the code that actually preempt the
thread.
> Adding a per-thread parameter (e.g., in struct thread) I could set
TDF_NEEDRESCHED when the dynamic time slice expires but how can I be sure the
thread gets preempted? Where can I set a per-thread parameter (maybe after
cpu_switch?!)? Is there a timer periodically calling a sort of context switch
function or the context switches happen only when triggered by the kernel
code?
TDF_NEEDRESCHED is checked for in ast() in sys/kern/subr_trap.c. It is called
during return to userland from interrupts, traps, and system calls.
--
John Baldwin
More information about the freebsd-hackers
mailing list