This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: pthread_attr_setsched behaviour
- From: Manuel Traut <manut at linutronix dot de>
- To: "Michael Kerrisk (man-pages)" <mtk dot manpages at gmail dot com>
- Cc: Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>, Siddhesh Poyarekar <siddhesh at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, Rich Felker <dalias at aerifal dot cx>
- Date: Thu, 18 Apr 2013 12:46:46 +0200
- 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> <CAAHN_R263JNgUMezfbtu-i_PT9Cd=rpqXWCgRdK=BdPVDxRZbQ at mail dot gmail dot com> <CAKgNAkirTJrjTUVGSgrRxR8iO_+PV+7c0nGx5kFD51_r1cUZMg at mail dot gmail dot com>
> > 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