pthread_join (BPX1PTJ, BPX4PTJ) — Wait on a thread
Function
The pthread_join callable service obtains the termination status for a specific thread. The pthread_join service waits only if the thread has not ended, is not in a detached state, and is not currently joined by another thread.
Requirements
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1PTJ): | 31-bit |
AMODE (BPX4PTJ): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
Format
CALL BPX1PTJ,(Thread_ID,
Status_field_address,
Return_value,
Return_code,
Reason_code)
AMODE 64 callers use BPX4PTJ with the same parameters. The Status_field_address parameter is a doubleword.
Parameters
- Thread_ID
- Supplied parameter
- Type:
- Character string
- Length:
- 8 bytes
The name of an 8-byte field that contains the thread ID for the target thread that is to be waited upon.
- Status_field_address
- Supplied parameter
- Type:
- Address
- Length:
- Fullword (doubleword)
The name of a fullword (doubleword) field that contains the address of a status field in which to return the exit status of the thread that is specified by the thread ID value. If this field is zero, the thread exit status is not returned.
- Return_Value
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the pthread_join service returns
0
if the request is successful, or-1
if it is not successful. - Return_Code
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the pthread_join service stores the return code. The pthread_join service returns Return_code only if Return_value is-1
. For a list of return code values, see Return codes (errnos) in z/OS UNIX System Services Messages and Codes. The pthread_join service can return one of the following values in the Return_code parameter:Return code Explanation EINTR The calling process received a signal before the completion of an event that would cause the pthread_join service to return. The service was interrupted by a signal. In this case, the value contained in Status_field_address is undefined. EINVAL The value that was specified by thread ID is not valid; it does not contain a value that is consistent with thread IDs managed by the system. The following reason code can accompany this return code: JRLightWeightThread. ESRCH The value that was specified by thread ID does not refer to a thread that is undetached. The following reason codes can accompany this return code: JRThreadNotFound, JRAlreadyJoined, and JRAlreadyDetached. EDEADLK A deadlock was detected; or the value specified by thread ID refers to the calling thread. The following reason codes can accompany this return code: JRJoinLoop and JRJoinToSelf. - Reason_Code
- Returned parameter
- Type:
- Integer
- Length:
- Fullword
The name of a fullword in which the pthread_join service stores the reason code. The pthread_join service returns Reason_code only if Return_value is
-1
. Reason_code further qualifies the Return_code value. For a list of reason codes, see Reason codes in z/OS UNIX System Services Messages and Codes.
Usage notes
- The pthread_join service can be called repeatedly for a thread until the thread is detached. However, a thread can be the target of only one pthread_join at a time.
- In AMODE 31, the status field pointed to by Status_Field_Addr is 4 bytes. In AMODE 64, the status field is 8 bytes. See pthread_create (BPX1PTC, BPX4PTC) — Create a thread for further information.
- When pthread_join is issued for a non-pthread-created thread that has ended, that thread will only be found if it exited via pthread_exit_and_get.
Related services
Characteristics and restrictions
There are no restrictions on the use of the pthread_join service.