From owner-freebsd-threads@FreeBSD.ORG Mon Jul 7 07:37:10 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6BF4437B401 for ; Mon, 7 Jul 2003 07:37:10 -0700 (PDT) Received: from silver.he.iki.fi (silver.he.iki.fi [193.64.42.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2B87143F93 for ; Mon, 7 Jul 2003 07:37:09 -0700 (PDT) (envelope-from pete@he.iki.fi) Received: from he.iki.fi (localhost.he.iki.fi [127.0.0.1]) by silver.he.iki.fi (8.12.9/8.11.4) with ESMTP id h67Eb7sL010840; Mon, 7 Jul 2003 17:37:07 +0300 (EEST) (envelope-from pete@he.iki.fi) Message-ID: <3F098593.8090605@he.iki.fi> Date: Mon, 07 Jul 2003 17:37:07 +0300 From: Petri Helenius User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3) Gecko/20030501 X-Accept-Language: English [en],Finnish [fi] MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-threads@freebsd.org Subject: Re: thread scheduling priority X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jul 2003 14:37:10 -0000 Daniel Eischen wrote: >First, you should say what threading library you are using. >I'll answer assuming you are using libkse (if you aren't, ignore me). > > I'll blame the heat for not mentioning that :-) Yes, I'm using libkse. >Try forcing libkse to use one KSE. By default, libkse will >create as many KSEs as CPUs that you have. It is possible > Actually it seems that it creates double the amount, because of the HypeThreading junk, although I have the logical secondary cores halted. I still believe it's a mistake not to allow them to "go away" altogether but have them configured confusing things like system utilities and in this case, libkse; # sysctl kern.threads.virtual_cpu=1 kern.threads.virtual_cpu: 4 -> 1 >that there is a problem with trying to keep both KSEs active >when you only have 2 threads and one or more of them block >or sleep. To do this, set kern.threads.debug=1 and >kern.threads.virtual_cpu=1: > > # sysctl kern.threads.debug=1 > # sysctl kern.threads.virtual_cpu=1 > >Also, the default scheduling policy is SCHED_RR and the RR >interval is 20msec. If your main thread is in a busy loop, >no other threads will run for 20 or so msec (assuming 1 KSE). > > Is there a way to hand over the mutex to the other thread when it's unlocked by the main thread? pthread_yield? Is that a no-op if there is no other runnable thread? I'd rather have both threads running while they can, using both CPUs. I assume the "correct" setting for virtual_cpu in my case would be 2 ? Pete obviously the other option is to