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 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.

[..]

> As Rich noted, the thing to do is improve the man page. Ehe EXAMPLE in
> the pthread_setschedparam(3) page does show the use of
> pthread_attr_setinheritsched() and the pthread_attr_setschedpolicy(3)
> page also points to that example, but the point should be more
> explicit in the main text of the DESCRIPTION in those two pages.

ACK

[..]

> >>> 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.
> 
> I have applied the patch below.

IMHO, the additional information would also apply for pthread_attr_setscope

> Thanks for the report.
 
Thanks for your patch,

  Manuel

> --- a/man3/pthread_attr_setschedparam.3
> +++ b/man3/pthread_attr_setschedparam.3
> @@ -71,6 +71,17 @@ As can be seen, only one scheduling parameter is supported.
>  For details of the permitted ranges for scheduling priorities
>  in each scheduling policy, see
>  .BR sched_setscheduler (2).
> +
> +In order for the parameter setting made by
> +.BR pthread_attr_setschedparam ()
> +to have effect when calling
> +.BR pthread_create (3),
> +the caller must use
> +.BR pthread_attr_setinheritsched (3)
> +to set the inherit-scheduler attribute of the attributes object
> +.I attr
> +to
> +.BR PTHREAD_EXPLICIT_SCHED .
>  .SH RETURN VALUE
>  On success, these functions return 0;
>  on error, they return a nonzero error number.
> diff --git a/man3/pthread_attr_setschedpolicy.3
> b/man3/pthread_attr_setschedpolicy.3
> index 46e5c2f..f96ad42 100644
> --- a/man3/pthread_attr_setschedpolicy.3
> +++ b/man3/pthread_attr_setschedpolicy.3
> @@ -69,6 +69,17 @@ returns the scheduling policy attribute of the
> thread attributes object
>  .IR attr
>  in the buffer pointed to by
>  .IR policy .
> +
> +In order for the policy setting made by
> +.BR pthread_attr_setschedpolicy ()
> +to have effect when calling
> +.BR pthread_create (3),
> +the caller must use
> +.BR pthread_attr_setinheritsched (3)
> +to set the inherit-scheduler attribute of the attributes object
> +.I attr
> +to
> +.BR PTHREAD_EXPLICIT_SCHED .
>  .SH RETURN VALUE
>  On success, these functions return 0;
>  on error, they return a nonzero error number.

-- 
Linutronix GmbH
 
Phone: +49 7556 / 91 98 91 
       +49 7542 / 98 04 82 
Fax:   +49 7556 / 91 98 86 

Firmensitz: D-88690 Uhldingen, Auf dem Berg 3
Registergericht: Freiburg i. Br., HRB 700 806;

Geschäftsführer: Heinz Egger, Thomas Gleixner


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