Skip Navigation Links | |
Exit Print View | |
Multithreaded Programming Guide Oracle Solaris 11.1 Information Library |
1. Covering Multithreading Basics
4. Programming with Synchronization Objects
5. Programming With the Oracle Solaris Software
6. Programming With Oracle Solaris Threads
Unique Oracle Solaris Threads Functions
Similar Synchronization Functions: Read-Write Locks
Initializing Read-Write Locks With Intraprocess Scope
Initializing Read-Write Locks With Interprocess Scope
Trying to Acquire a Write Lock
Destroying the Read-Write Lock State
Similar Oracle Solaris Threads Functions
Getting the Minimal Stack Size
Acquiring the Thread Identifier
Access the Signal Mask of the Calling Thread
Creating a Thread-Specific Data Key
Setting the Thread-Specific Data Value
Getting the Thread-Specific Data Value
Similar Synchronization Functions: Mutual Exclusion Locks
Mutexes With Intraprocess Scope
Mutexes With Interprocess Scope
Mutexes With Interprocess Scope-Robust
Similar Synchronization Functions: Condition Variables
Initialize a Condition Variable
Condition Variables With Intraprocess Scope
Condition Variables With Interprocess Scope
Destroying a Condition Variable
cond_reltimedwait Return Values
Similar Synchronization Functions: Semaphores
Semaphores With Intraprocess Scope
Semaphores With Interprocess Scope
sema_destroy(3C) Return Values
Synchronizing Across Process Boundaries
Example of Producer and Consumer Problem
Special Issues for fork() and Oracle Solaris Threads
The Oracle Solaris threads API and the pthreads API are two solutions to the same problem: build parallelism into application software. Although each API is complete, you can safely mix Oracle Solaris threads functions and pthread functions in the same program.
The two APIs do not match exactly, however. Oracle Solaris threads support functions that are not found in pthreads, and pthreads include functions that are not supported in the Oracle Solaris interface. For those functions that do match, the associated arguments might not, although the information content is effectively the same.
By combining the two APIs, you can use features not found in one API to enhance the other API. Similarly, you can run applications that use Oracle Solaris threads exclusively with applications that use pthreads exclusively on the same system.
Oracle Solaris threads and pthreads are very similar in both API action and syntax. The major differences are listed in Table 6-1 .
Table 6-1 Unique Oracle Solaris Threads and pthreads Features
|
The following table compares Oracle Solaris threads functions with pthreads functions. Note that even when Oracle Solaris threads and pthreads functions appear to be essentially the same, the arguments to the functions can differ.
When a comparable interface is not available either in pthreads or Oracle Solaris threads, a hyphen `-' appears in the column. Entries in the pthreads column that are followed by (3RT) are functions in librt, the POSIX.1b Realtime Extensions library, which is not part of pthreads. Functions in this library provide most of the interfaces specified by the POSIX.1b Realtime Extension.
Table 6-2 Oracle Solaris Threads and POSIX pthreads Comparison
|
To use the Oracle Solaris threads functions described in this chapter for Solaris 9 and previous releases, you must link with the Oracle Solaris threads library -lthread .
Operation is virtually the same for both Oracle Solaris threads and for pthreads, even though the function names or arguments might differ. Only a brief example consisting of the correct include file and the function prototype is presented. Where return values are not given for the Oracle Solaris threads functions, see the appropriate pages in man pages section 3: Basic Library Functions for the function return values.
For more information on Oracle Solaris related functions, see the related pthreads documentation for the similarly named function.
Where Oracle Solaris threads functions offer capabilities that are not available in pthreads, a full description of the functions is provided.