This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pthread_attr_setsched behaviour


On Tue, Apr 16, 2013 at 03:32:11PM +0200, Manuel Traut wrote:
> Hi,
> 
> i just recognized, that calling:
> 
> ret |= pthread_attr_setschedpolicy (..)
> ret |= pthread_attr_setschedparam (..)
> ret |= pthread_create (..)
> 
> doesn't return an error and the values set by pthread_attr_setschedparam and
> pthread_attr_setschedpolicy aren't applied to the thread.
> 
> The APPLICATION USAGE of the functions say:
> 
>    After  these attributes have been set, a thread can be created with the
>    specified attributes using pthread_create(). Using these routines  does
>    not affect the current running thread.
> 
> So I didn't expect that I need to call:
> pthread_attr_setinheritsched before pthread_create.
> 
> I would like to improve the current behaviour, with a little patch;
> please give me some directions...
> 
> Is there a reason why e.g. pthread_attr_set_schedparam doesn't set
> iattr->flags |= ATTR_FLAG_NOTINHERITSCHED

The POSIX specification doesn't tell us that we ought to do this.  If
we do, we might end up breaking compatibility.

> Or is it better to return an error code in pthread_attr_setschedparam, etc if
> ATTR_FLAG_NOTINHERITSCHED isn't set?

This is wrong since one is allowed to set NOTINHERITSCHED after
setschedparam.

> If both is bad, at least the man page should mention the need of calling
> pthread_attr_setinheritsched..

This is the best option currently.  I've added Michael Kerrisk to cc;
he maintains the man pages.

Siddhesh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]