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
Comparing APIs for Oracle Solaris Threads and POSIX 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
Prior to the Oracle Solaris 10 release, Oracle Solaris threads and POSIX threads defined the behavior of fork() differently. See Process Creation: exec and exit Issues for a thorough discussion of fork() issues.
Oracle Solaris libthread supported both fork() and fork1(). The fork() call has “fork-all” semantics. fork() duplicated everything in the process, including threads and LWPs, creating a true clone of the parent. The fork1() call created a clone that had only one thread. The process state and address space are duplicated, but only the calling thread was cloned.
POSIX libpthread supported only fork(), which has the same semantics as fork1() in Oracle Solaris threads.
Whether fork() has “fork-all” semantics or “fork-one” semantics was dependent on which library is used. Link with -lthread to assign “fork-all” semantics to fork(). Link with -lpthread to assign “fork-one” semantics to fork().
Effective with the Oracle Solaris 10 release, fork() has the same semantics in both Oracle Solaris threads and POSIX threads. More specifically, fork1() semantics replicate only the caller. A new function, forkall() , is provided for those applications that require replicate-all semantics.
See Compiling and Linking a Multithreaded Program for more details.