From owner-freebsd-threads@FreeBSD.ORG Sat Aug 5 00:06:30 2006 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from localhost.my.domain (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 2033016A4DE; Sat, 5 Aug 2006 00:06:30 +0000 (UTC) (envelope-from davidxu@freebsd.org) From: David Xu To: freebsd-threads@freebsd.org Date: Sat, 5 Aug 2006 08:06:24 +0800 User-Agent: KMail/1.8.2 References: <20060804140657.GK4498@obiwan.tataz.chchile.org> <200608041134.43979.john@baldwin.cx> In-Reply-To: <200608041134.43979.john@baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608050806.24502.davidxu@freebsd.org> Cc: John Baldwin Subject: Re: system scope vs. process scope X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Aug 2006 00:06:30 -0000 On Friday 04 August 2006 23:34, John Baldwin wrote: > Suppose you have a system with 2 processes. One process is single-threaded > and is CPU bound. The other process has 2 threads both of which are also > CPU bound. If the threads in the second process are PTHREAD_SCOPE_SYSTEM, > then each thread will get 33% of the CPU. If the threads in the second > process are PTHREAD_SCOPE_PROCESS, then the each process will get 50% of > the CPU. The second process will then use its own algorithm to split it's > 50% of the CPU up between it's two threads. If it divides it evenly, then > each of its' threads will end up with 25% of the CPU whereas the thread for > the first process has 50% of the CPU. The idea for this is that if you > have a system with several single-threaded processes and one process with > 1000 threads, you don't want that process to starve out all the other > processes. > I can make my application fork 800 processes and starve out all the other user. > In practice things get much hairier, but suffice it to say that libpthread > manages the scheduling of PTHREAD_SCOPE_PROCESS threads in userland, > whereas libthr would have to depend on the kernel managing that. (To some > extent libpthread needs some help from the kernel to provide this as well.) The complete solution is FSS (fair sharing schedule) found in Solaris. David Xu