Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000792 [1003.1(2013)/Issue7+TC1] Base Definitions and Headers Objection Omission 2013-11-15 05:23 2013-11-15 05:29
Reporter eblake View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Eric Blake
Organization Red Hat
User Reference ebb.thread_lifetime
Section 3.399 Thread ID
Page Number 97
Line Number 2704
Interp Status ---
Final Accepted Text
Summary 0000792: better definition of thread lifetime
Description 0000765 identified that while we have a definition for Process Lifetime, we do not have a counterpart definition for Thread Lifetime. The desired action attempts to align with concepts introduced in the resolution of 0000690.

Furthermore, 0000765 identified some future directions for use in Issue 7; this bug targets Issue 8 and turns those future directions into requirements (namely, that a thread ID must not cause ESRCH errors if its lifetime has not elapsed; comparable to kill() vs. process lifetime).

Finally, the wording in XSH 2.9.2 page 513 line 17651 could be construed as claiming that a thread ID can be reused as soon as pthread_detach has been called for a thread (by parsing as "The lifetime of a thread ID ends [after the thread terminates if it was created with the detachstate attribute set to
PTHREAD_CREATE_DETACHED] or [if pthread_detach( ) or pthread_join( ) has been called for that thread]." where the later condition takes effect the moment the thread is detached without waiting for the thread termination). But intuitively, a thread ID must exist until the later of thread termination and the point where the thread is no longer joinable, with several ways of becoming non-joinable. After all, it is certainly reasonable to use a thread ID of long-running thread that has had pthread_detach() called on it as the argument to pthread_kill() so long as the thread has not terminated.
Desired Action [Editor's Note: This adds several new definition sections. In
particular, 0000690 inserts a new section "Live Process" in the same
place as this proposal adds "Live Thread". Make sure that the
additions remain in sorted order, and that all sections are numbered
appropriately afterwards. I sorted "Thread Termination" before
"Thread-Safe" based on the existing precedence of "Priority
Scheduling" before "Priority-Based Scheduling" at 3.288. The
remainder of this request refers only to existing TC1 section
numbering and references to new section names.]

After Issue7+TC1 XBD section 3.209 ("Link Count") page 66 line 1935,
insert a new section Live Thread with the following contents
(copied from the existing text at 3.398 Thread, with a minor
change):

A single flow of control within a process. Each thread has its own
thread ID, scheduling priority and policy, errno value,
floating point environment, thread-specific key/value bindings, and
the required system resources to support a flow of control. Anything
whose address may be determined by a thread, including but not limited
to static variables, storage obtained via malloc( ), directly
addressable storage obtained through implementation-defined functions,
and automatic variables, are accessible to all live threads in the
same process.

<small>Note: The malloc( ) function is defined in detail
in the System Interfaces volume of POSIX.1-2008.</small>


At XBD section 3.398 ("Thread") line 2695 page 97, change:

A single flow of control within a process. Each thread has its own
thread ID, scheduling priority and policy, errno value,
floating point environment, thread-specific key/value bindings, and
the required system resources to support a flow of control. Anything
whose address may be determined by a thread, including but not limited
to static variables, storage obtained via malloc( ), directly
addressable storage obtained through implementation-defined functions,
and automatic variables, are accessible to all live threads in the
same process.

<small>Note: The malloc( ) function is defined in detail
in the System Interfaces volume of
POSIX.1-2008.</small>
to:

A live thread (see [xref to Live Thread]) or a zombie thread (see
[xref to Zombie Thread]). The lifetime of a thread is described in
[xref to Thread Lifetime].


After XBD section 3.399 ("Thread ID") page 97 line 2704, insert a new
section Thread Lifetime with contents:

The period of time that begins when a thread is created and ends when
its thread ID is returned to the process.

See also Live Thread in [xref to Live Thread], Thread
Termination
in [xref to Thread Termination], and Zombie
Thread
in [xref to Zombie Thread].

<small>Note: Thread creation is defined in detail in the
descriptions of the pthread_create( ) function in the System
Interfaces volume of POSIX.1-2008.</small>


After XBD section 3.400 ("Thread List") page 98 line 2708, insert a
new section Thread Termination with contents:

A thread is terminated when it executes pthread_exit( ), when
it completes execution of the entry point passed to
pthread_create( ), or by cancellation via another thread's use
of pthread_cancel( ).

<small>Note: The pthread_cancel( ),
pthread_create( ), and pthread_exit( ) functions are
defined in detail in the System Interfaces volume of
POSIX.1-2008.</small>


After XBD section 3.446 ("Zombie Process") page 105 line 2872, add a
new section Zombie Thread with contents:

The remains of a joinable live thread (see [xref to Live Thread])
after it terminates (see [xref to Thread Termination]) and before it
has been joined with pthread_join( ) or detached with
pthread_detach( ).

<small>Note: The pthread_detach( ) and
pthread_join( ) functions are defined in detail in the System
Interfaces volume of POSIX.1-2008.</small>


At XSH section 2.9.2 ("Thread IDs") page 513 line 17651,
change:

The lifetime of a thread ID ends after the thread terminates if it was
created with the detachstate attribute set to
PTHREAD_CREATE_DETACHED or if pthread_detach( ) or
pthread_join( ) has been called for that
thread.
to:

The lifetime of a thread ID ends after the later of thread termination
and the point when the thread is no longer joinable (either the thread
was created with the detachstate attribute set to
PTHREAD_CREATE_DETACHED, or pthread_detach( ) or
pthread_join( ) has been called for the thread).


At XSH pthread_cancel page 1586 line 51364 (DESCRIPTION), add a new
sentence:

It shall not be an error to request cancellation of a zombie
thread.


After XSH pthread_cancel page 1586 line 51398 (RATIONALE), add a new
paragraph:

Historical implementations varied on the result of a
pthread_cancel( ) with a thread ID indicating a zombie
thread. Some indicated success with nothing further to do because the
thread had already terminated, while others gave an error of [ESRCH].
Since the definition of thread lifetime in this standard covers zombie
threads, the [ESRCH] error as described is inappropriate in this case
and implementations that give this error do not conform.


At XSH pthread_detach page 1619 line 52452 (DESCRIPTION),
change:

If thread has not terminated, pthread_detach( ) shall
not cause it to terminate.
to:

If thread has not terminated, pthread_detach( ) shall
not cause it to terminate, but shall prevent the thread from becoming
a zombie thread when it does terminate.


At XSH pthread_join page 1632 line 52856 (DESCRIPTION),
change:

a thread that has exited but remains
unjoined
to:

a joinable zombie thread


At XSH pthread_kill page 1640 line 53156 (DESCRIPTION), add a
sentence:

It shall not be an error if thread is a zombie
thread.


At XSH pthread_kill page 1640 line 53174 (RATIONALE), change the
wording introduced by 0000765:

Existing implementations vary on the result of a pthread_kill( )
with thread id indicating an inactive thread (a terminated
thread that has not been detached or
joined).
to:

Historical implementations vary on the result of a
pthread_kill( ) on a thread indicating a zombie
thread.
.

At XSH pthread_kill page 1640 line 53176 (FUTURE DIRECTIONS), revert
the entire paragraph introduced by 0000765:

A future version of this standard may require that
pthread_kill( ) not fail with ESRCH in the case of sending
signals to an inactive thread (a terminated thread not yet detached or
joined), even though no signal will be delivered because the thread is
no longer running.
back to:
None.

Tags No tags attached.
Attached Files

- Relationships
related to 0000765Closed kill and pthread_kill behavior between termination and lifetime end 
related to 0000690Closed clarify behavior when calling waitpid with SA_NOCLDWAIT 

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2013-11-15 05:23 eblake New Issue
2013-11-15 05:23 eblake Name => Eric Blake
2013-11-15 05:23 eblake Organization => Red Hat
2013-11-15 05:23 eblake User Reference => ebb.thread_lifetime
2013-11-15 05:23 eblake Section => 3.399 Thread ID
2013-11-15 05:23 eblake Page Number => 97
2013-11-15 05:23 eblake Line Number => 2704
2013-11-15 05:23 eblake Interp Status => ---
2013-11-15 05:23 eblake Tag Attached: issue8
2013-11-15 05:23 eblake Relationship added related to 0000765
2013-11-15 05:24 eblake Relationship added related to 0000690
2013-11-15 05:29 eblake Desired Action Updated
2019-05-23 16:08 geoffclare Tag Detached: issue8


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker