From owner-freebsd-performance@FreeBSD.ORG Fri Dec 5 15:01:10 2008 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78EAD1065675 for ; Fri, 5 Dec 2008 15:01:10 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: from mail-qy0-f18.google.com (mail-qy0-f18.google.com [209.85.221.18]) by mx1.freebsd.org (Postfix) with ESMTP id 1B7C38FC12 for ; Fri, 5 Dec 2008 15:01:09 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: by qyk11 with SMTP id 11so42161qyk.19 for ; Fri, 05 Dec 2008 07:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=4HizaYceovFblLjsUDXRv7wINU1s3cFBaQWAkEKxP/U=; b=LN1HI6K4V1op8e82KUaPLGtbw/Z9moaDaBv9HtceZYthaxhjNt9cDFF/bfgFHfmBqx g2UVe4FMu8PK0eCsQshjR1K+4IOoJ/4v4EKHlIgcKZxEHYB6XwRwFvAECQPwchADTvum +dAgqW/8RNjn/kRcSd/ZfL7LLpgGVXdl1GiFI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=k/Q0GTEeDeaFAVacXOqU9n7/d6zlWlha6fxjb6XYmCTtfNtm2tfnxmslBwcoyQrlX4 2SB2CZiCDN71UmB8PUMslul3zk4HwPtx8sPBLtDrepeihY77Jlj8IQAdB9Lwfu5HPA3V IVCMaJgkF0q7GTzty9sMxXAH40TGEv1j8E34I= Received: by 10.214.60.1 with SMTP id i1mr129201qaa.286.1228489269076; Fri, 05 Dec 2008 07:01:09 -0800 (PST) Received: by 10.214.243.19 with HTTP; Fri, 5 Dec 2008 07:01:09 -0800 (PST) Message-ID: <584ec6bb0812050701t4bcccb1fr214370f4535ae1d0@mail.gmail.com> Date: Fri, 5 Dec 2008 15:01:09 +0000 From: "Ray Kinsella" To: freebsd-performance@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Thread priority in FreeBSD X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2008 15:01:10 -0000 Hi all, I have a problem trying to influence thread scheduling in FreeBSD. There are three threads I am interested the priority of:- a. Enqueue Thread: - Enqueues data in a circular buffer b. Interrupt Handler: - Signals that data in the circular buffer has been processed and in ready for removal - Queues an entry on a task queue so the data is removed from the circular buffer asynchronousily - Data is processed by a pci card c. Task Queue Thread: - Dequeues request from a task queue. - Dequeues data from the circular buffer. *Objective: *I want to prioritise the *Enqueue Thread, *such that it will always executes until the circular buffer is exhausted of space. I want the *Task Queue Thread* to have the lowest priority such that it only runs when the *Enqueue Thread* has no work to do. *Observed behaviour: *I set the *Enqueue Thread, *to have a priority of PRI_MAX_KERN (0) I set the *Task Queue Thread,* to have a priority of PRI_MIN_KERN (64) In the main I see the following scheduling:- ... *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread, *puts requests on a taskqueue for async processing. *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread**, *puts requests on a taskqueue for async processing. *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer .. No matter what I do with thread priorities, the *Task Queue Thread *always follows the *Interrupt Handler. * *Ideal behaviour* Ideally I would get the following behaviour, were *Enqueue Thread *will always run instead of *Task Queue Thread *thread while it has work to do. *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread, *puts requests on a taskqueue for async processing. *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread**, *puts requests on a taskqueue for async processing. *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread**, *puts requests on a taskqueue for async processing. *Enqueue Thread, *yields timeslices as the circular buffer is maxed out *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer Any idea's how to encourage the scheduler to adopt this behaviour ? Thanks Ray Kinsella * *