Email List: Xaustin-group-lX
[All Lists]

Re: Defect in XSH pthread_attr_getschedparam/pthread_attr_setschedparamA

To: yyyyyyyy@xxxxxxxxxx
Subject: Re: Defect in XSH pthread_attr_getschedparam/pthread_attr_setschedparamALSO pthread_attr_getschedparam and sched.h
From: Dave Butenhof <yyyyyyyyyyyyyy@xxxxxx>
Date: Fri, 05 Nov 2004 09:12:36 -0500
Cc: yyyyyyyyyyyyyy@xxxxxxxxxxxxx
Organization: HP MSL
References: <200411050655.GAA10572@xoneweb.opengroup.org>
yyyyyyyy@xxxxxxxxxx wrote:

Defect report from : Natarajan Krishnaswami , IBM

(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)

@ page 0 line 0 section pthread_attr_getschedparam/pthread_attr_setschedparam ALSO pthread_attr_getschedparam and sched.h comment {nk-sched}

Problem:

Edition of Specification (Year): 2004

Defect code : 2. Omission

The pthread_attr_getschedparam() and pthread_attr_getschedparam() interfaces are part of the threads option. However, they take as an argument a pointer to a sched_param structure. This structure is declared in sched.h, which is dependent on the process scheduling option.

http://www.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getschedparam.html
http://www.opengroup.org/onlinepubs/009695399/basedefs/sched.h.html


Action:

Below, [x> and <x] represent the opt-start and opt-end symbols.

The thread option needs to require the presence of sched.h:
Change the specification of sched.h from
NAME
sched.h - execution scheduling (REALTIME)
SYNOPSIS
[PS] [x> #include <sched.h> <x]
to
NAME
sched.h - execution scheduling
SYNOPSIS
[THR|PS] [x> #include <sched.h> <x]

Perhaps better, pthread_attr_getschedparam() and pthread_attr_setschedparam() should be part of an option that requires both threads and process scheduling, such as thread execution scheduling (of which pthread_setschedparam() and pthread_getschedparam() are part).
Change the specifications of pthread_attr_get/setschedparam from
NAME
pthread_attr_getschedparam, pthread_attr_setschedparam - get and set the schedparam attribute
SYNOPSIS
[THR] [x> #include <pthread.h>
int pthread_attr_getschedparam(const pthread_attr_t *restrict attr,
struct sched_param *restrict param);
int pthread_attr_setschedparam(pthread_attr_t *restrict attr,
const struct sched_param *restrict param); <x]
to (something like)
NAME
pthread_attr_getschedparam, pthread_attr_setschedparam - get and set the schedparam attribute (REALTIME THREADS)
SYNOPSIS
[THR TPS] [x> #include <pthread.h>
int pthread_attr_getschedparam(const pthread_attr_t *restrict attr,
struct sched_param *restrict param);
int pthread_attr_setschedparam(pthread_attr_t *restrict attr,
const struct sched_param *restrict param); <x]

This is an interesting issue. It's a "POSIX to SUS translation issue", in essence, because POSIX never made the existence of header files conditional. (Until and except for the threads option, there was no attempt or intent to even make interfaces optional; "unimplemented" optional functions simply returned ENOSYS before that. The change in policy for threads was controversial and difficult, and the issues continued to pop up for years.)

In fact, I'm not convinced that SUS really intends to mark header file existence as optional. I don't recall any discussion of this before, and can't see any text that clearly documents such an intent. Yes, it's true that the <sched.h> summary page in XBD marks the #include <sched.h> with [PS]. However, the synopsis is documented as showing application USE of the header, not whether the header exists. (It's incorrect in any case, since it's valid and necessary to include <sched.h> under [TPS] or even [THR].)

As for moving the schedparam attributes functions out of the base [THR] option into [TPS]; this is an ancient issue that goes way back into the drafts of 1003.1c. They were put there deliberately to support the "common practice" of some form of priority scheduling even on systems that didn't do POSIX priority scheduling. "A standard way to be nonstandard" was a common working group mantra. While I was never quite convinced this made any sense, the (relatively few) strong supporters were unswerving; and nobody else really felt quite strongly enough to pursue the argument. (Note that only the attributes functions, and not the pthread_{s|g}etschedparam functions, were in this category because the feeling was that "everyone" would allow CREATING threads with some sort of priority, but not everyone would necessarily support dynamically changing the priority after creation.)

So I agree the synopsis of <sched.h> should be marked THR as well as PS (TPS would be redundant).

Attachment: david.butenhof.vcf
Description: Text Data

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Defect in XSH pthread_attr_getschedparam/pthread_attr_setschedparamALSO pthread_attr_getschedparam and sched.h, Dave Butenhof <=