From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 25 04:21:14 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 70CC2756 for ; Mon, 25 Nov 2013 04:21:14 +0000 (UTC) Received: from sender1.zohomail.com (sender1.zohomail.com [72.5.230.103]) by mx1.freebsd.org (Postfix) with ESMTP id 5B7D628D8 for ; Mon, 25 Nov 2013 04:21:14 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type; b=vctXyKy85gk7AeEUFwNftlSVebPae/+BIunoRVKGMj6i1UvT1B0lwbRfgtaCU9SARw1ZLJabluIk iAV/kGK1lvuZXGuqsLE+H5QcDnZ0dokNFjXsmUOlDZwJpwEOEQyK Received: from [192.168.2.5] (224-8-237-24.gci.net [24.237.8.224]) by mx.zohomail.com with SMTPS id 1385350141362643.8981711911233; Sun, 24 Nov 2013 19:29:01 -0800 (PST) Message-ID: <5292C3F9.5060908@zoho.com> Date: Sun, 24 Nov 2013 18:28:57 -0900 From: zbr User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: hiren panchasara , "freebsd-hackers@freebsd.org" Subject: Re: ULE thread scheduling in -head References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ZohoMailClient: External X-Zoho-Virus-Status: 2 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Nov 2013 04:21:14 -0000 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