For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > February 2007 > sched_setscheduler and threads









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author sched_setscheduler and threads
Spoon

2007-02-07, 7:06 pm

Hello,

(I use Linux 2.6 and NPTL if it matters.)

I have an application where I use sched_setscheduler to change the
policy to SCHED_RR.

http://www.opengroup.org/onlinepubs...tscheduler.html

What happens if I create threads within this application before I call
sched_setscheduler? Will they run in SCHED_RR?

The Open Group Base Specifications Issue 6 states:

<quote>

The effect of this function on individual threads is dependent on the
scheduling contention scope of the threads:

For threads with system scheduling contention scope, these functions
shall have no effect on their scheduling.

For threads with process scheduling contention scope, the threads'
scheduling policy and associated parameters shall not be affected.
However, the scheduling of these threads with respect to threads in
other processes may be dependent on the scheduling parameters of their
process, which are governed using these functions.

If an implementation supports a two-level scheduling model in which
library threads are multiplexed on top of several kernel-scheduled
entities, then the underlying kernel-scheduled entities for the system
contention scope threads shall not be affected by these functions.

The underlying kernel-scheduled entities for the process contention
scope threads shall have their scheduling policy and associated
scheduling parameters changed to the values specified in policy and
param, respectively. Kernel-scheduled entities for use by process
contention scope threads that are created after this call completes
shall inherit their scheduling policy and associated scheduling
parameters from the process.

This function is not atomic with respect to other threads in the
process. Threads may continue to execute while this function call is in
the process of changing the scheduling policy and associated scheduling
parameters for the underlying kernel-scheduled entities used by the
process contention scope threads.

</quote>

Errr... What does this all mean to Linux 2.6 and NPTL?

Regards.
Loic Domaigne

2007-02-07, 7:06 pm

Hello

> (I use Linux 2.6 and NPTL if it matters.)
>
> I have an application where I use sched_setscheduler to change the
> policy to SCHED_RR.
>
> http://www.opengroup.org/onlinepubs...ched_setsche...
>
> What happens if I create threads within this application before I call
> sched_setscheduler? Will they run in SCHED_RR?
>
> The Open Group Base Specifications Issue 6 states:


<snip>

> Errr... What does this all mean to Linux 2.6 and NPTL?


It basically means that the operation is a NOP for threading library
using a 1:1 model, as it is the case for NPTL.

A human readable version of the text you quoted can be found at:
http://groups.google.com/group/comp...6f150f42bbd7ecb

HTH,
Loic.

Olivier Croquette

2007-02-11, 7:08 pm


Follow-up set.


Spoon wrote, On 07.02.2007 17:58 Uhr:

> What happens if I create threads within this application before I call
> sched_setscheduler? Will they run in SCHED_RR?


Last time I played around with sched_setscheduler, it changed the
priority of the single thread given.

And this is no typo: sched_setscheduler was working with thread ids as
well as with process ids.

See also the following discussion
<http://linux.derkeiler.com/Mailing-...05-05/4193.html>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com