This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: pthread_attr_setsched behaviour
- From: Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>, Michael Kerrisk <mtk dot manpages at gmail dot com>
- Cc: Manuel Traut <manut at linutronix dot de>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 18 Apr 2013 08:25:25 +0530
- Subject: Re: pthread_attr_setsched behaviour
- References: <20130416133211 dot GB15869 at linutronix dot de> <20130417124952 dot GF10160 at spoyarek dot pnq dot redhat dot com>
OK, *now* I've added Michael Kerrisk to cc :)
Siddhesh
On 17 April 2013 18:19, Siddhesh Poyarekar <siddhesh@redhat.com> wrote:
> 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
--
http://siddhesh.in