Thread priority in FreeBSD

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Thread priority in FreeBSD

Ray Kinsella
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

*


*
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Thread priority in FreeBSD

Ray Kinsella
Apologies, I neglected to clarify, I am of course talking about Kernel
Threads.

On Fri, Dec 5, 2008 at 3:01 PM, Ray Kinsella <[hidden email]>wrote:

> 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
>
> *
>
>
> *
>
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "[hidden email]"