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

Re: Defect in XSH pthread_attr_getscope()

To: yyyyyyy@xxxxxxxxxx
Subject: Re: Defect in XSH pthread_attr_getscope()
From: Dave Butenhof <yyyyyyyyyyyyyy@xxxxxx>
Date: Thu, 13 Feb 2003 06:50:35 -0500
Cc: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Organization: Hewlett-Packard Company
References: <200302130943.JAA17607@xxxxxx>
yyyyyyy@xxxxxxxxxx wrote:

	Defect report from : Ulrich Drepper , Red Hat

(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)

@ page 991 line 31490 section pthread_attr_getscope() objection {ptattr-3}

Problem:

Defect code :  2. Omission

The standard does not mention anywhere the default value of the value retrieved via pthread_attr_getscope() after a call to
pthread_attr_init().

The pthread_attr_getguardsize() man page does contain the appropriate information.

I don't know what the default value should be.  If I would have to pick I'd chose PTHREAD_SCOPE_SYSTEM.

Action:

Add new paragraph after line 31490 either:

 The default value of the /contentionscope/ attribute is <t>PTHREAD_SCOPE_SYSTEM<t>


or

 The default value of the /contentionscope/ attribute is <t>PTHREAD_SCOPE_PROCESS<t>

Again, this is deliberately unspecified. The standard, first off, requires only that AT LEAST ONE of the two defined scheduling contention scopes be implemented. Specifying the default would conflict with that flexibility. (We might consider requiring that IF the implementation provides only ONE of the two contention scopes, then it must default the attribute to the one it defines. In POSIX this sort of issue was generally considered "quality of implementation" rather than something to be mandated by the standard, though.)

Oh, and, by the way, the standard doesn't actually say that the "default value" must be one of the defined constants for these attributes. On Solaris, for example, the default stack size is 0. Since nobody can legally set a value of 0, pthread_create() knows to replace the value 0 with the actual stack size. This has the annoying side effect that one cannot fetch and perform computations on the default (e.g., to run with 1/2, or twice, the default), but it's not illegal.

Similarly, it'd be legal (if odd) for the default contention scope value to be "0", while system and process were defined to 1 and 2, so that pthread_create() could distinguish and supply the true default.

POSIX simply doesn't have enough constraints to support 'get' operations on any of these attributes until they have been set by the application. I found this unfortunate when I discovered it, but I suppose I've gotten over it. "Late binding" does provide some advantages, after all.

--
/--------------------[ yyyyyyyyyyyyyy@xxxxxx ]--------------------\
| Hewlett-Packard Company Tru64 UNIX & VMS Thread Architect |
| My book: http://www.awl.com/cseng/titles/0-201-63392-2/ |
\----[ http://homepage.mac.com/dbutenhof/Threads/Threads.html ]---/


<Prev in Thread] Current Thread [Next in Thread>