Terminating pthreads

Note: If multiple threads are created with a combination of pthread_create and dubbed MVS™ tasks, the following termination methods do not apply. The exception to this, of course, is that the IPT is a dubbed task. If the IPT has any subtasks that are non-pthread threads, the following termination scenarios also do not apply.

There are no prescribed methods for terminating threads that are mixed with other dubbed tasks in a single process.

There are three ways to terminate a thread without exiting the process:
  • The pthread_exit_and_get (BPX1PTX) service terminates the thread that invoked it. If it is successful, control is returned to the invoking task.
  • The pthread_cancel (BPX1PTB) service generates a cancel request to the target thread. After the cancel request is delivered, the thread and its associated task are terminated by the kernel. This behavior can be circumvented if the thread intercepts the cancelation request (see mvssigsetup (BPX1MSS, BPX4MSS) — Set up MVS signals).
  • The pthread_quiesce (BPX1PTQ) service sends a quiesce event to all other pthreads in the process. If the other pthreads do not intercept the quiesce event (see mvssigsetup (BPX1MSS, BPX4MSS) — Set up MVS signals), delivery of the event terminates the thread and the task, if the target is not the IPT.

The two types of threads that are created with pthread_create require different actions for terminating.