From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 8 14:08:12 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 68F8F1065676 for ; Thu, 8 Jan 2009 14:08:12 +0000 (UTC) (envelope-from ulf.lilleengen@gmail.com) Received: from bene2.itea.ntnu.no (bene2.itea.ntnu.no [IPv6:2001:700:300:3::57]) by mx1.freebsd.org (Postfix) with ESMTP id 0CBB28FC35 for ; Thu, 8 Jan 2009 14:08:11 +0000 (UTC) (envelope-from ulf.lilleengen@gmail.com) Received: from localhost (localhost [127.0.0.1]) by bene2.itea.ntnu.no (Postfix) with ESMTP id 9197790004; Thu, 8 Jan 2009 15:08:09 +0100 (CET) Received: from carrot (unknown [IPv6:2001:700:300:3::184]) by bene2.itea.ntnu.no (Postfix) with ESMTP id 396CB90002; Thu, 8 Jan 2009 15:08:09 +0100 (CET) Date: Thu, 8 Jan 2009 16:08:08 +0100 From: Ulf Lilleengen To: Mehmet Ali Aksoy =?iso-8859-1?B?VNxZU9xa?= Message-ID: <20090108150807.GA1264@carrot.pvv.ntnu.no> References: <14ded62c0901080123u7268055epb3e17d84aa757051@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14ded62c0901080123u7268055epb3e17d84aa757051@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Debian amavisd-new at bene2.itea.ntnu.no Cc: freebsd-hackers@freebsd.org Subject: Re: Threads and SMP kernel scheduling X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 14:08:12 -0000 On Thu, Jan 08, 2009 at 04:23:08AM -0500, Mehmet Ali Aksoy TÜYSÜZ wrote: > Hi all, > > After I had a bit googling I got confused. > > My questions are simple and they are as follows : > > 1-) "Are pthreads (or threads in general) of one process scheduled to > different cores on multi-core systems running Linux or BSD?" > The standard threading library in FreeBSD will use a 1:1 mapping between userland threads(pthreads) and kernel threads. This means that each thread may run on a different core than other threads. > 2-) What if there are multiple processes which have multiple threads? Does > it change the answer of (1)? No, the same mapping applies. Although threads of one process may preferably run on the same core, each thread of a process may run on any of the cores available. > > I found some answers but they are not sharp. Somebody says "can be > scheduled" but "can be" is not a precise answer (in my opinion.) Well, it means that there are more factors deciding where a thread is put. If you look at a factor such as affinity, one thread may preferable be scheduled to the same core since the cache may contain data relevant to the thread. > > Thanks everybody in advance. > Hope everything is at least a bit clearer. -- Ulf Lilleengen