Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Nov 2013 18:28:57 -0900
From:      zbr <lukasz.wojcik@zoho.com>
To:        hiren panchasara <hiren.panchasara@gmail.com>,  "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: ULE thread scheduling in -head
Message-ID:  <5292C3F9.5060908@zoho.com>
In-Reply-To: <CALCpEUFpOjGGw1Ys4fTyB24gRQ-ab3X_qzrTqUNpjBBSZnP84g@mail.gmail.com>
References:  <CALCpEUFpOjGGw1Ys4fTyB24gRQ-ab3X_qzrTqUNpjBBSZnP84g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/14/2013 23:30, hiren panchasara wrote:
> I want to understand how thread affinity works and for that I need to
> understand how scheduling works. I am reading things and trying to map
> them to the code in FreeBSD-head (in and around sys/kern/sched_ule.c)
>
> In terms of scheduler queues, I found 2 different things:
> 1)
> "ULE: A Modern Scheduler For FreeBSD" paper from jeffr mentions
> following in 3.1 Queue Mechanisms:
> Fairness is implemented by keeping two queues; current and next. Each
> thread that is granted a
> slice is assigned to either the current queue or the next queue.
>
> 2)
> I found another interesting struct in there: struct tdq - per
> processor runqs and statistics which has 3 queues: realtime, timeshare
> and idle.
>
> I could not find 1) in source code.
>
> Can someone throw some light on how a thread gets scheduled? Do 1) and
> 2) both exist and work together currently in -head FreeBSD?
>
> Trying to follow the code, sched_setup() calls sched_setup_smp() where
> for each cpu we call tdq_setup() where we initialize 3 queues
> mentioned in 2)  -- But it seems this is all one time setup on boot.
> What happens when a new thread is spawned?
>
> Any good pointer/reference for further reading would be great.
>
> cheers,
> Hiren
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
>

Hi Hiren,

As far as I know two different schedulers exist in BSD (you can use 
either one):

1) ULE scheduler (sys/kern/sched_ule.c) -- That's the one described in 
the paper mentioned by you,

2) Old 4BSD scheduler (sys/kern/kern_4bsd.c)

Thanks,
-LW




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