Subroutines defined in the POSIX thread standard

We have categorized the Pthread subroutines defined in the POSIX thread standard, which are supported on AIX, into the following:

Thread management sub-routinesSee Table D-1.
Execution scheduling sub-routinesSee Table D-2 on page 476.
Synchronization sub-routinesSee Table D-3 on page 477.
Thread-specific data sub-routinesSee Table D-4 on page 479.

Table D-1. Thread management sub-routines
NameDescription
pthread_attr_init()Initializes a thread attributes object.
pthread_attr_destroy()Destroys a thread attributes object.
pthread_attr_setdetachstate()Sets the detachstate attribute of a thread attributes object. This attribute determines if a thread created with this thread attributes object is in a detached state or not.
pthread_attr_getdetachstate()Gets the detach state attribute from a thread attributes object.
pthread_attr_setstackaddr()Sets the value of the stackaddr attribute of a thread attributes object. This attribute specifies the stack address of a thread created with this attributes object.
pthread_attr_getstackaddr()Gets the stackaddr attribute from a thread attributes object.
pthread_attr_setstacksize()Sets the value of the stacksize attribute of a thread attributes object. This attribute specifies the minimum stack size, in bytes, of a thread created with this thread attributes object.
pthread_attr_getstacksize()Gets the stacksize attribute from a thread attributes object.
pthread_testcancel()Creates a cancellation point in the calling thread.
pthread_setcancelstate()Atomically sets the calling thread’s cancelability state to the indicated state and returns the previous cancelability state at a specified location reference.
pthread_setcanceltype()Atomically sets the calling thread’s cancelability type to the indicated type and returns the previous cancelability type at a specified location reference.
pthread_create()Creates a new thread and initializes its attributes using the thread attributes object specified, or standard values instead, if the NULL pointer is specified. After thread creation, a thread attributes object can be reused to create another thread, or deleted.
pthread_exit()Terminates the calling thread safely, and stores a termination status for any thread that may join the calling thread.
pthread_cancel()Requests the cancellation of the specified thread. The action depends on the cancelability of the target thread.
pthread_kill()Sends the specified signal to the specified thread. It acts with threads like the kill subroutine with single-threaded processes.
pthread_join()Blocks the calling thread until the specified thread terminates. If the specified thread is in a detached state (non-joinable), an error is returned.
pthread_detach()Used to indicate to the implementation that storage for the specified thread can be reclaimed when that thread terminates.
pthread_once()Executes the specified routine exactly once in a process. The first call to this subroutine by any thread in the process executes the given routine, without parameters. Any subsequent call will have no effect.
pthread_self()Returns the calling thread’s ID.
pthread_equal()Compares the two specified thread IDs. Returns zero if and only if the IDs are equal.
pthread_atfork()Threads can fork processes. This routine registers fork cleanup handlers. Three handlers can be specified: prepare, parent, and child. The prepare handler is called before the processing of the fork subroutine commences. The parent handler is called after the processing of the fork subroutine completes in the parent process. The child handler is called after the processing of the fork subroutine completes in the child process.
pthread_cleanup_push()Pushes the specified cancellation cleanup handler routine onto the calling thread’s cancellation cleanup stack.
pthread_cleanup_pop()Removes the routine at the top of the calling thread’s cancellation cleanup stack and optionally invokes it (if execute is non-zero).

Table D-2. Execution scheduling sub-routines
NameDescription
pthread_attr_setschedparam()Sets the value of the schedparam attribute of the specified thread attributes object. The given schedparam attribute specifies the scheduling parameters of a thread created with this attributes object.
pthread_attr_getschedparam()Gets the value of the schedparam attribute of the specified thread attributes object.
pthread_attr_setscope()The contention scope can only be set before thread creation by setting the contention-attribute of a thread attributes object. The pthread_attr_setscope subroutine sets the attribute to the specified value.
pthread_attr_getscope()Gets the contention-scope attribute of the specified thread attributes object.
pthread_attr_setinheritsched()Sets the inheritsched attribute of the specified thread attributes object to a given value.
pthread_attr_getinheritsched()Gets the inheritsched attribute of the specified thread attributes object.
pthread_attr_setschedpolicy()Sets the schedpolicy attribute of the specified thread attributes object.
pthread_attr_getschedpolicy()Gets the schedpolicy attribute of the specified thread attributes object.
pthread_setschedparam()Dynamically sets the schedpolicy and schedparam attributes of the specified thread. The given schedpolicy attribute specifies the scheduling policy of the thread. The given schedparam attribute specifies the scheduling parameters. The implementation of this subroutine is dependent on the priority scheduling POSIX option. The priority scheduling POSIX option is implemented in the operating system. If the target thread has system contention-scope, the process must have root authority to set the scheduling policy to either SCHED_FIFO or SCHED_RR.
pthread_getschedparam()Returns the current schedpolicy and schedparam attributes of the thread thread. The schedpolicy attribute specifies the scheduling policy of a thread.

Table D-3. Synchronization sub-routines
NameDescription
pthread_mutexattr_init()Initializes a mutex attributes object with the default value for all of the attributes defined by the implementation.
pthread_mutexattr_destroy()Destroys a mutex attributes object; the object becomes, in effect, uninitialized.
pthread_mutexattr_setpshared()Sets the process-shared attribute in a given initialized attributes object.
pthread_mutexattr_getpshared()Obtains the value of the process-shared attribute from the given attributes object.
pthread_mutex_init()Initializes the given mutex with attributes specified by a given attributes object. If the attributes object is NULL, the default mutex attributes are used.
pthread_mutex_destroy()Destroys the specified mutex object; the mutex object becomes, in effect, uninitialized.
pthread_mutex_lock()The specified mutex object is locked by calling. If the mutex is already locked, the calling thread blocks until the mutex becomes available.
pthread_mutex_trylock()Identical to pthread_mutex_lock(), except that if the referenced mutex object is currently locked (by any thread, including the current thread), the call returns immediately.
pthread_mutex_unlock()Releases the referenced mutex object. The manner in which a mutex is released is dependent upon the mutex’s type attribute.
pthread_condattr_init()Initializes a specified condition variable attributes object with the default value for all of the attributes defined by the implementation.
pthread_condattr_destroy()Destroys a specified condition variable attributes object; the object becomes, in effect, uninitialized.
pthread_condattr_setpshared()Sets the value of the pshared attribute of the specified condition attributes object. This attribute specifies the process sharing of the condition variable created with this attributes object.
pthread_condattr_getpshared()Returns the value of the pshared attribute of the specified condition attribute object. This attribute specifies the process sharing of the condition variable created with this attributes object.
pthread_cond_init()Initializes the given condition variable with attributes given by a condition attributes object. If that object is NULL, the default condition variable attributes are used.
pthread_cond_destroy()Destroys the given condition variable; the object becomes, in effect, uninitialized.
pthread_cond_wait()Blocks on a condition variable. Must be called with a specified mutex locked by the calling thread or undefined behavior will result.
pthread_cond_timedwait()Same as pthread_cond_wait(), except that an error is returned if the specified absolute time passes (that is, system time equals or exceeds the specified absolute time) before the specified condition is signaled or broadcasted, or if the absolute time specified has already been passed at the time of the call.
pthread_cond_signal()Unblocks one or more threads blocked on the specified condition.
pthread_cond_broadcast()Unblocks all the blocked threads on the specified condition.

Table D-4. Thread-specific data sub-routines
NameDescription
pthread_key_create()Creates a thread-specific data key. The key is shared among all threads within the process, but each thread has specific data associated with the key. The thread-specific data is a void pointer, initially set to NULL. An optional destructor routine can be specified. It will be called for each thread when it is terminated and detached, after the call to the cleanup routines, if the specific value is not NULL.
pthread_key_delete()Deletes the given thread-specific data key previously created with the pthread_key_create() subroutine. The application must ensure that no thread-specific data is associated with the key.
pthread_setspecific()Associates a thread-specific value with a key obtained through a previous call to pthread_key_create(). Different threads may bind different values to the same key.
pthread_getspecific()Returns the value currently bound to the specified key on behalf of the calling thread.

Note

Currently, AIX does not support the following sub-routines. Although the symbols are provided in the Pthread library, but calls to these routines always return with ENOSYS:

  • pthread_mutexattr_setprioceiling()

  • pthread_mutexattr_getprioceiling()

  • pthread_mutexattr_setprotocol()

  • pthread_mutexattr_getprotocol()

  • pthread_mutex_setprioceiling()

  • pthread_mutex_getprioceiling()


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset