Date: Tue, 11 Oct 2011 08:26:31 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-hackers@freebsd.org Cc: Riccardo Cattaneo <cattaneo.riccardo@gmail.com> Subject: Re: 4.4BSD timeslice management Message-ID: <201110110826.31499.jhb@freebsd.org> In-Reply-To: <127B21EE-2730-4463-8921-B79CCE2B5ECB@gmail.com> References: <127B21EE-2730-4463-8921-B79CCE2B5ECB@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110110826.31499.jhb>