Notes |
(0001406)
geoffclare (manager)
2012-10-22 08:03
|
Implementations can have two versions of sleep(): one in libc that uses
SIGALRM and one in libpthread that does not.
Instead of removing the text relating to SIGALRM, it should be made
conditional on the program not having been linked with -l pthread.
For example, a new second paragraph could be added to the DESCRIPTION
saying something like:
In programs linked without -l pthread (see [xref to XCU c99]), sleep()
may make use of SIGALRM. In programs linked with -l pthread, sleep()
shall not make use of SIGALRM and the remainder of this DESCRIPTION
does not apply. |
|
(0001407)
dalias (reporter)
2012-10-22 13:03
|
To my knowledge, the language "linked with[out]" is not used elsewhere in the standard. Also, the semantics of the c99 utility seem to apply only to implementations that support the [CD] option, so it is less than optimal for the semantics of sleep() to be specified in terms of behavior of the c99 utility.
Rather than making the behavior conditional on "linking", why not use something along the lines of the following:
"In any program which has or may come to have multiple threads, the remainder of this DESCRIPTION shall not apply; in particular, sleep() shall not alter any signal dispositions."
This also allows implementations that choose a version of sleep based on runtime characteristics, or weak symbols, or some other mechanism different from -l options when linking. |
|
(0001428)
geoffclare (manager)
2012-12-05 17:41
|
This was discussed in the 5th December teleconference and some
additional issues were noted:
If an application is not linked with -l pthread but the implementation
might create additional threads "under the covers" of its own accord,
then the implementation should not use SIGALRM in sleep().
If an application is not linked with -l pthread but later uses
dlopen() to load either libpthread or a library that has libpthread as
a dependency, and then creates an additional thread, this could result
in the SIGALRM-based sleep() being used while the process is
multithreaded. This is a more general problem that affects more
things than sleep(), and the standard should say the behaviour is
undefined if an application does this.
The consensus was that we should eliminate all of the problems
associated with SIGALRM-based sleep by disallowing it in Issue 8, and
a Future Directions note should be added in TC2 to warn about this.
However, something still needs to be done in TC2 to resolve the
problem with Issue 7 without requiring implementations to change. |
|
(0001430)
geoffclare (manager)
2012-12-12 17:38
edited on: 2012-12-20 16:59
|
Interpretation response
------------------------
The standard does not speak to this issue, and as such no conformance distinction can be made between alternative implementations based on
this. This is being referred to the sponsor.
Rationale:
-------------
The standard does not adequately address the differences
between single-threaded and multi-threaded processes and
programs.
Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
Add a new paragraph after page 1963 line 62339:
In single-threaded programs, sleep() may make use of SIGALRM. In
multi-threaded programs, sleep() shall not make use of SIGALRM and
the remainder of this DESCRIPTION does not apply.
On page 1963 line 62369 in the RATIONALE change:
This volume of POSIX.1-2008 permits either approach.
to
This volume of POSIX.1-2008 permits either approach in
single-threaded programs, but the simple alarm/suspend
implementation is not appropriate for multi-threaded programs.
On page 1964 line 62406 change the FUTURE DIRECTIONS section from:
None.
to:
A future version of this standard may require that sleep() does
not make use of SIGALRM in all programs, not just multi-threaded
programs.
Cross-volume changes to XBD...
Add the following definitions in XBD chapter 3, in alphabetical order:
Multi-threaded library
A library containing object files that were produced by compiling with c99
using the flags output by getconf POSIX_V7_THREADS_CFLAGS, or by
compiling using a non-standard utility with equivalent flags, and
which makes use of interfaces that are only made available by c99 when
the -l pthread option is used or makes use of SIGEV_THREAD notifications.
Multi-threaded process
A process that contains more than one thread.
Multi-threaded program
A program whose executable file was produced by compiling with c99
using the flags output by getconf POSIX_V7_THREADS_CFLAGS, and linking
with c99 using the flags output by getconf POSIX_V7_THREADS_LDFLAGS
and the -l pthread option, or by compiling and linking using a
non-standard utility with equivalent flags. Execution of a
multi-threaded program initially creates a single-threaded process;
the process can create additional threads using pthread_create() or
SIGEV_THREAD notifications.
Single-threaded process
A process that contains a single thread.
Single-threaded program
A program whose executable file was produced by compiling with c99
without using the flags output by getconf POSIX_V7_THREADS_CFLAGS and
linking with c99 using neither the flags output by getconf
POSIX_V7_THREADS_LDFLAGS nor the -l pthread option, or by compiling
and linking using a non-standard utility with equivalent flags.
Execution of a single-threaded program creates a single-threaded
process; if the process attempts to create additional threads using
pthread_create() or SIGEV_THREAD notifications, the behavior is
undefined. If the process uses dlopen() to load a multi-threaded
library, the behavior is undefined.
|
|
(0001520)
ajosey (manager)
2013-03-29 08:05
|
Interpretation Proposed 29 Mar 2013 |
|
(0001575)
ajosey (manager)
2013-05-03 12:19
|
Interpretation approved 3 May 2013 |
|