From owner-freebsd-threads@FreeBSD.ORG Mon Jul 7 07:14:04 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 4241937B401 for ; Mon, 7 Jul 2003 07:14:04 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 965D143F75 for ; Mon, 7 Jul 2003 07:14:03 -0700 (PDT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h67EE2AI006639; Mon, 7 Jul 2003 10:14:02 -0400 (EDT) Date: Mon, 7 Jul 2003 10:14:02 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Petri Helenius In-Reply-To: <3F096E56.4010609@he.iki.fi> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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:14:04 -0000 On Mon, 7 Jul 2003, Petri Helenius wrote: > I have two threads on a SMP (2 CPU, HT disabled) box with world+kernel > from mid-June. (cvsupping to latest right now) and a process which > runs two threads with the following code snippet, more or less in a process > & maintenance (collecting statistics, doing housekeeping, etc.) fashion. > While > the main thread does it's stuff it competes for a mutex with the other > thread. However > I'm observing that the thread created in the snippet below has hard time > getting > scheduled while the main thread is running. First, you should say what threading library you are using. I'll answer assuming you are using libkse (if you aren't, ignore me). Try forcing libkse to use one KSE. By default, libkse will create as many KSEs as CPUs that you have. It is possible 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). -- Dan Eischen