Skip Navigation Links | |
Exit Print View | |
Multithreaded Programming Guide Oracle Solaris 11.1 Information Library |
1. Covering Multithreading Basics
Waiting for Thread Termination
Creating a Key for Thread-Specific Data
pthread_key_create Return Values
Deleting the Thread-Specific Data Key
pthread_key_delete Return Values
pthread_setspecific Return Values
pthread_getspecific Return Values
Global and Private Thread-Specific Data Example
Calling an Initialization Routine for a Thread
Setting the Thread Policy and Scheduling Parameters
pthread_setschedparam Return Values
Getting the Thread Policy and Scheduling Parameters
pthread_getschedparam Return Values
pthread_setschedprio Return Values
Accessing the Signal Mask of the Calling Thread
Enabling or Disabling Cancellation
pthread_setcancelstate Return Values
pthread_setcanceltype Return Values
pthread_testcancel Return Values
Pushing a Handler Onto the Stack
pthread_cleanup_push Return Values
Pulling a Handler Off the Stack
pthread_cleanup_pop Return Values
4. Programming with Synchronization Objects
5. Programming With the Oracle Solaris Software
6. Programming With Oracle Solaris Threads
When a thread is created, a new thread of control is added to the current process. Every process has at least one thread of control, in the program's main() routine. Each thread in the process runs simultaneously, and has access to the calling process's global data. In addition each thread has its own private attributes and call stack.
To create a new thread, a running thread calls the pthread_create() function, and passes a pointer to a function for the new thread to run. One argument for the new thread's function can also be passed, along with thread attributes. The execution of a thread begins with the successful return from the pthread_create() function. The thread ends when the function that was called with the thread completes normally.
A thread can also be terminated if the thread calls a pthread_exit() routine, or if any other thread calls pthread_cancel() to explicitly terminate that thread. A thread can also be terminated by the exit of the process that called the thread.