thr_intro(3)
NAME
thr_intro - Introduction to DCE Threads
DESCRIPTION
DCE Threads is a set of routines that you can call to create a multithreaded program. Multithreading is used to improve the performance of a program. Routines implemented by DCE Threads that are not specified by Draft 4 of the POSIX 1003.4a standard are indicated by an _np suffix on the name. These routines are new primitives. The Threads routines sort alphabetically in the reference pages; however, the tables in this introduction list the routines in the following functional groups:
•Threads Routines
•Routines that Implicitly Initialize Threads Package
•Attributes Object Routines
•Mutex Routines
•Condition Variable Routines
•Thread-Specific Data Routines
•Threads Cancellation Routines
•Threads Priority and Scheduling Routines
•Cleanup Routines
•The atfork() Routine
•Signal Handling Routines
| Threads Routines | |
| Routine | Description |
| pthread_create() | Creates a thread |
| pthread_delay_np() | Causes a thread to wait for a period of time |
| pthread_detach() | Marks a thread for deletion |
| pthread_equal() | Compares one thread identifier to another thread identifier |
| pthread_exit() | Terminates the calling thread |
| pthread_join() | Causes the calling thread to wait for the termination of a specified thread |
| pthread_once() | Calls an initialization routine to be executed only once |
| pthread_self() | Obtains the identifier of the current thread |
| pthread_yield() | Notifies the scheduler that the current thread will release its processor to other threads of the same or higher priority |
The following DCE Threads routines will, when called, implicitly perform any necessary initialization of the Threads package. Thus any application using DCE Threads should call one of the following routines before calling any other Threads routines, in order to ensure that the package is properly initialized.
| Routines that Implicitly Perform Threads Initialization | |
| Routine | Description |
| pthread_attr_create() | Creates a thread attributes object |
| pthread_create() | Creates a thread |
| pthread_self() | Obtains the identifier of the current thread |
| pthread_setprio() | Changes the scheduling priority attribute |
| pthread_getprio() | Obtains the scheduling priority attribute |
| pthread_setscheduler() | Changes the scheduling policy attribute |
| pthread_getscheduler() | Obtains the scheduling policy attribute |
| pthread_once() | Calls an initialization routine to be executed only once |
| pthread_keycreate() | Generates a unique thread-specific data key value |
| pthread_mutexattr_create() | Creates a mutex attributes object |
| pthread_mutex_init() | Creates a mutex |
| pthread_condattr_create() | Creates a condition variable attributes object |
| pthread_cond_init() | Creates a condition variable |
| pthread_testcancel() | Requests delivery of a pending cancel |
| pthread_setcancel() | Enables or disables the current thread’s general cancelability |
| pthread_setasynccancel() | Enables or disables the current thread’s asynchronous cancelability |
| pthread_delay_np() | Causes a thread to wait for a period of time |
| Attributes Object Routines | |
| Routine | Description |
| pthread_attr_create() | Creates a thread attributes object |
| pthread_attr_delete() | Deletes a thread attributes object |
| pthread_attr_getinheritsched() | Obtains the inherit scheduling attribute |
| pthread_attr_getprio() | Obtains the scheduling priority attribute |
| pthread_attr_getsched() | Obtains the scheduling policy attribute |
| pthread_attr_getstacksize() | Obtains the stacksize attribute |
| pthread_attr_setinheritsched() | Changes the inherit scheduling attribute |
| pthread_attr_setprio() | Changes the scheduling priority attribute |
| pthread_attr_setsched() | Changes the scheduling policy attribute |
| pthread_attr_setstacksize() | Changes the stacksize attribute |
| pthread_condattr_create() | Creates a condition variable attributes object |
| pthread_condattr_delete() | Deletes a condition variable attributes object |
| pthread_mutexattr_create() | Creates a mutex attributes object |
| Deletes a mutex attributes object | |
| pthread_mutexattr_getkind_np() | Obtains the mutex type attribute |
| pthread_mutexattr_setkind_np() | Changes the mutex type attribute |
| Mutex Routines | |
| Routine | Description |
| pthread_lock_global_np() | Locks a global mutex |
| pthread_mutex_destroy() | Deletes a mutex |
| pthread_mutex_init() | Creates a mutex |
| pthread_mutex_lock() | Locks a mutex and waits if the mutex is already locked |
| pthread_mutex_trylock() | Locks a mutex and returns if the mutex is already locked |
| pthread_mutex_unlock() | Unlocks a mutex |
| pthread_unlock_global_np() | Unlocks a global mutex |
| Condition Variable Routines | |
| Routine | Description |
| pthread_cond_broadcast() | Wakes all threads waiting on a condition variable |
| pthread_cond_destroy() | Deletes a condition variable |
| pthread_cond_init() | Creates a condition variable |
| pthread_cond_signal() | Wakes one thread waiting on a condition variable |
| pthread_cond_timedwait() | Causes a thread to wait for a specified period of time for a |
| condition variable to be signaled or broadcast | |
| pthread_cond_wait() | Causes a thread to wait for a condition variable to be signaled or broadcast |
| pthread_get_expiration_np() | Obtains a value representing a desired expiration time |
| Thread-Specific Data | |
| Routine | Description |
| pthread_getspecific() | Obtains the thread-specific data associated with the specified key |
| pthread_keycreate() | Generates a unique thread-specific data key value |
| pthread_setspecific() | Sets the thread-specific data associated with the specified key |
| Threads Cancellation Routines | |
| Routine | Description |
| pthread_cancel() | Allows a thread to request termination |
| pthread_setasynccancel() | Enables or disables the current thread’s asynchronous cancelability |
| pthread_setcancel() | Enables or disables the current thread’s general cancelability |
| pthread_signal_to_cancel_np() | Cancels a thread if a signal is received by the process |
| pthread_testcancel() | Requests delivery of a pending cancel |
| Threads Priority and Scheduling Routines | |
| Routine | Description |
| pthread_getprio() | Obtains the current priority of a thread |
| pthread_getscheduler() | Obtains the current scheduling policy of a thread |
| pthread_setprio() | Changes the current priority of a thread |
| pthread_setscheduler() | Changes the current scheduling policy and priority of a thread |
| Cleanup Routines | |
| Routine | Description |
| pthread_cleanup_pop() | Removes a cleanup handler from the stack |
| pthread_cleanup_push() | Establishes a cleanup handler |
| The atfork() Routine | |
| Routine | Description |
| atfork() | Arranges for fork cleanup handling |
| Signal Handling Routines | |
| Routine | Description |
| sigaction() | Specifies action to take on receipt of signal |
| sigpending() | Examines pending signals |
| sigprocmask() | Sets the current signal mask |
| sigwait() | Causes thread to wait for asynchronous signal |
Hewlett-Packard Company — OSF DCE 1.1/HP DCE 1.5