Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Mar 2008 09:17:50 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Andriy Gapon <avg@icyb.net.ua>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: sched_ule: roundrobin_callout replacement ?
Message-ID:  <200803060917.50328.jhb@freebsd.org>
In-Reply-To: <47CFF43A.9070704@icyb.net.ua>
References:  <47B9A359.9080502@icyb.net.ua> <200803060755.04607.jhb@freebsd.org> <47CFF43A.9070704@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 06 March 2008 08:40:10 am Andriy Gapon wrote:
> on 06/03/2008 14:55 John Baldwin said the following:
> > On Monday 18 February 2008 10:25:13 am Andriy Gapon wrote:
> >> I see that sched_4bsd has a NOP callout with a purpose of forcing a
> >> context switch (via softclock), so that something like a preemption
> >> could happen (e.g. for threads in a tight calculation loop).
> >> What serves the similar purpose for sched_ule?
> >> Or, how sched_ule deals with the issue without needing softclock's help?
> >
> > It's gone in newer versions of 4BSD in HEAD actually.  ULE does it by
> > checking in sched_clock() to see if the current thread has used up its
> > quantum.  If so it sets TDF_NEEDRESCHED.
>
> Thank you. But where/when does actual thread switch happens?
> E.g. I have two userland processes that do something like "while(1);",
> what is the event that can switch from one to the other?

TDF_NEEDRESCHED is checked on return to userland from interrupts, traps, and 
system calls.  The clock interrupt that sets TDF_NEEDRESCHED will check for 
it on the way back to userland and invoke ast() (sys/kern/subr_trap.c) which 
will end up forcing a context switch.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803060917.50328.jhb>