Contained WithinFind More DocumentationFeatured Support Resources | Download this book in PDF (1975 KB)
pthreads(5)Name | Synopsis | Description | Function Comparison | Locking | SCHEDULING | Errors | Usage | Attributes | See Also Name
Synopsiscc –mt [ flag... ] file... [ -lrt library... ] #include <pthread.h> Solariscc –mt [ flag... ] file... [ library... ] #include <sched.h> #include <thread.h> Description
POSIX and Solaris threads each have their own implementation within libc(3LIB). Both implementations are interoperable, their functionality similar, and can be used within the same application. Only POSIX threads are guaranteed to be fully portable to other POSIX-compliant environments. POSIX and Solaris threads require different source, include files and linking libraries. See SYNOPSIS. SimilaritiesMost of the POSIX and Solaris threading functions have counterparts with each other. POSIX function names, with the exception of the semaphore names, have a “pthread” prefix. Function names for similar POSIX and Solaris functions have similar endings. Typically, similar POSIX and Solaris functions have the same number and use of arguments. DifferencesPOSIX pthreads and Solaris threads differ in the following ways: Function ComparisonThe following table compares the POSIX pthreads and Solaris threads functions. When a comparable interface is not available either in POSIX pthreads or Solaris threads, a hyphen (–) appears in the column. Functions Related to Creation
Functions Related to ExitFunctions Related to Thread Specific Data
Functions Related to SignalsFunctions Related to IDsFunctions Related to Scheduling
Functions Related to Cancellation
Functions Related to Mutexes
Functions Related to Condition Variables
Functions Related to Reader/Writer Locking
Functions Related to Semaphores
Functions Related to fork( ) Clean UpFunctions Related to LimitsFunctions Related to DebuggingLockingSynchronizationMultithreaded behavior is asynchronous, and therefore, optimized for concurrent and parallel processing. As threads, always from within the same process and sometimes from multiple processes, share global data with each other, they are not guaranteed exclusive access to the shared data at any point in time. Securing mutually exclusive access to shared data requires synchronization among the threads. Both POSIX and Solaris implement four synchronization mechanisms: mutexes, condition variables, reader/writer locking (optimized frequent-read occasional-write mutex), and semaphores. Synchronizing multiple threads diminishes their concurrency. The coarser the grain of synchronization, that is, the larger the block of code that is locked, the lesser the concurrency. MT fork()If a threads program calls fork(2), it implicitly calls fork1(2), which replicates only the calling thread. Should there be any outstanding mutexes throughout the process, the application should call pthread_atfork(3C) to wait for and acquire those mutexes prior to calling fork(). SCHEDULING
POSIXScheduling allocation size per thread is greater than one. POSIX supports the following three scheduling policies: SolarisOnly scheduling policy supported is SCHED_OTHER, which is timesharing, based on the TS scheduling class. ErrorsIn a multithreaded application, EINTR can be returned from blocking system calls when another thread calls forkall(2). Usage-mt compiler optionThe -mt compiler option compiles and links for multithreaded code. It compiles source files with -D_REENTRANT and augments the set of support libraries properly. AttributesSee attributes(5) for descriptions of the following attributes:
See Alsocrle(1), fork(2), libpthread(3LIB), librt(3LIB), libthread(3LIB), pthread_atfork(3C), pthread_create(3C), attributes(5), standards(5) Name | Synopsis | Description | Function Comparison | Locking | SCHEDULING | Errors | Usage | Attributes | See Also |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||