View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000792 | 1003.1(2013)/Issue7+TC1 | Base Definitions and Headers | public | 2013-11-15 05:23 | 2024-06-11 09:02 |
Reporter | eblake | Assigned To | |||
Priority | normal | Severity | Objection | Type | Omission |
Status | Closed | Resolution | Accepted As Marked | ||
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 | 0000792:0005923 | ||||
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):
At XBD section 3.398 ("Thread") line 2695 page 97, change: to:
After XBD section 3.399 ("Thread ID") page 97 line 2704, insert a new section Thread Lifetime with contents:
After XBD section 3.400 ("Thread List") page 98 line 2708, insert a new section Thread Termination with contents:
After XBD section 3.446 ("Zombie Process") page 105 line 2872, add a new section Zombie Thread with contents:
At XSH section 2.9.2 ("Thread IDs") page 513 line 17651, change: to:
At XSH pthread_cancel page 1586 line 51364 (DESCRIPTION), add a new sentence:
After XSH pthread_cancel page 1586 line 51398 (RATIONALE), add a new paragraph:
At XSH pthread_detach page 1619 line 52452 (DESCRIPTION), change: to:
At XSH pthread_join page 1632 line 52856 (DESCRIPTION), change: to:
At XSH pthread_kill page 1640 line 53156 (DESCRIPTION), add a sentence:
At XSH pthread_kill page 1640 line 53174 (RATIONALE), change the wording introduced by 0000765: to: . At XSH pthread_kill page 1640 line 53176 (FUTURE DIRECTIONS), revert the entire paragraph introduced by 0000765: back to: None. | ||||
Tags | issue8 |
|
The following is the desired action with a few wording changes based on the email discussion in Nov 2013 and some updates to include C17 threads. Page and line numbers have been updated to be for Issue 8 draft 2.1. [Editor's Note: This adds several new definition sections. 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". The remainder of this request refers only to existing D2.1 section numbering and references to new section names.] After XBD section 3.177 ("Job Control Job ID") page 54 line 1718, insert a new section Joinable Thread with the following contents: A thread that was created either using pthread_create() with the detachstate attribute not set to PTHREAD_CREATE_DETACHED or using thrd_create(), and for which neither pthread_detach() nor pthread_join() has been called and returned zero, and neither thrd_detach() nor thrd_join() has been called and returned <tt>thrd_success</tt>. After XBD section 3.183 ("Live Process") page 55 line 1738, insert a new section Live Thread with the following contents (copied from the existing text at 3.372 Thread, with two minor changes): 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 can 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. At XBD section 3.372 ("Thread") page 82 line 2490, 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.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.373 ("Thread ID") page 82 line 2499, 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. After XBD section 3.374 ("Thread List") page 82 line 2503, insert a new section Thread Termination with contents: Thread termination occurs when a thread executes pthread_exit() or thrd_exit(), when it returns from the start_routine function passed to pthread_create() or from the func function passed to thrd_create(), or when it acts on a cancellation request initiated by pthread_cancel(). After XBD section 3.408 ("Zombie Process") page 87 line 2638, add a new section Zombie Thread with contents: The remains of a joinable live thread (see [xref to Joinable Thread] and [xref to Live Thread]) after it terminates (see [xref to Thread Termination]) and before it has been joined with pthread_join() or thrd_join() or detached with pthread_detach() or thrd_detach(). At XSH section 2.9.2 ("Thread IDs") page 501 line 17748, after applying bug 1302, change: The lifetime of a thread ID ends after the thread terminates if it was created using pthread_create() with the detachstate attribute set to PTHREAD_CREATE_DETACHED or if pthread_detach(), pthread_join(), thrd_detach(), or thrd_join() has been called for that thread.to: The lifetime of a thread ID ends after the later of thread termination (see [xref to Thread Termination]) and the point when the thread is no longer joinable (see [xref to Joinable Thread]). At XSH pthread_cancel page 1553 line 51305 (DESCRIPTION), add a new sentence: It shall not be an error to request cancellation of a zombie thread. After XSH pthread_cancel page 1553 line 51340 (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 1587 line 52443 (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 1598 line 52801 (DESCRIPTION), change: a thread that has exited but remains unjoinedto: a zombie thread At XSH pthread_kill page 1606 line 53102 (DESCRIPTION), add a sentence: It shall not be an error if thread is a zombie thread. At XSH pthread_kill page 1606 line 53124 (RATIONALE), change: Existing implementations vary on the result of a pthread_kill() with a thread ID indicating an inactive thread (a terminated thread that has not been detached or joined). Some indicate success on such a call, while others give an error of [ESRCH]. Since the definition of thread lifetime in this volume of POSIX.1-202x covers inactive threads, the [ESRCH] error as described is inappropriate in this case.to: Historical implementations varied on the result of a pthread_kill() with a thread ID indicating a zombie thread. Some indicated success on such a call, while others gave an error of [ESRCH]. Since the definition of thread lifetime in this volume of POSIX.1-202x 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_kill page 1606 line 53132 (FUTURE DIRECTIONS), change: 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.to: None. |
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 | |
2022-08-02 14:53 | geoffclare | Note Added: 0005923 | |
2022-08-02 14:55 | geoffclare | Relationship added | related to 0001302 |
2022-08-04 15:07 | geoffclare | Final Accepted Text | => 0000792:0005923 |
2022-08-04 15:07 | geoffclare | Status | New => Resolved |
2022-08-04 15:07 | geoffclare | Resolution | Open => Accepted As Marked |
2022-08-04 15:07 | geoffclare | Tag Attached: issue8 | |
2022-08-19 15:23 | geoffclare | Status | Resolved => Applied |
2024-06-11 09:02 | agadmin | Status | Applied => Closed |