4.4BSD timeslice management
cattaneo.riccardo at gmail.com
Wed Oct 5 16:55:09 UTC 2011
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?
More information about the freebsd-hackers