Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Dec 2008 15:09:56 +0000
From:      "Ray Kinsella" <raykinsella78@gmail.com>
To:        freebsd-drivers@freebsd.org
Subject:   Kernel Thread priority in FreeBSD
Message-ID:  <584ec6bb0812050709p309d406ax7e22d1fad8ad9719@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi all,

I am reposting this from the performance list, as it might be a better forum
for the question.

I have a problem trying to influence kernel 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

*


*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?584ec6bb0812050709p309d406ax7e22d1fad8ad9719>