scl_thread_intro(3scl)scl_thread_intro(3scl)NAMEscl_thread_intro - Introduction to the Solaris Compatibility Libraries'
Thread Library.
LIBRARY
SCL Threads Library (libthread.so)
DESCRIPTION
The Solaris Thread Library (STL) is a component of the Solaris Compati‐
bility Libraries (SCL) for Tru64 UNIX. STL provides an implementation
of the Solaris-specific application programming interface (API) for
thread functions and synronization objects, which are layered upon the
POSIX threads library provided with Tru64 UNIX.
Functionality
The following tables list the supported functionality provided by STL:
Synchronization Object Functions ----------------------
---------
Condition Variables [1] cond_init(3scl)cond_destroy(3scl)cond_broadcast(3scl)cond_signal(3scl)cond_timedwait(3scl)cond_wait(3scl)
Mutexes [1] mutex_init(3scl)mutex_destroy(3scl)mutex_lock(3scl)mutex_trylock(3scl)mutex_unlock(3scl)
Readers/writer Locks [1] rwlock_init(3scl)rwlock_destroy(3scl)rw_rdlock(3scl)rw_tryrdlock(3scl)rw_trywrlock(3scl)rw_unlock(3scl)rw_wrlock(3scl)
Semaphores sema_init(3scl)sema_destroy(3scl)sema_post(3scl)sema_trywait(3scl)sema_wait(3scl)
Thread Management Functions -----------------
---------
Create and destroy [2] thr_create(3scl)thr_exit(3scl)thr_kill(3scl)
Join [3] thr_join(3scl)
Suspend and continue [4] thr_suspend(3scl)thr_continue(3scl)
Priority [5] thr_getprio(3scl)thr_setprio(3scl)
Identification thr_self(3scl)thr_main(3scl)
Scheduling thr_getconcurrency(3scl)thr_setconcurrency(3scl)thr_yield(3scl)
Thread-specific data thr_getspecific(3scl)thr_setspecific(3scl)thr_keycreate(3scl)
Stack thr_min_stack(3scl)thr_stksegment(3scl) [6]
Signals thr_sigsetmask(3scl)
Notes
SCL version 1.0 supports process-wide (USYNC_THREAD) condition vari‐
ables, mutexes and readers/writer locks. System-wide (USYNC_PROCESS)
synchronization objects are unsupported with this version.
SCL version 1.0 supports the creation of daemon, detached and suspended
threads but not bound threads. Supports join-specific-thread and join-
any-thread. A patch may need to be applied to Tru64 UNIX in order for
suspend/continue to function correctly. SCL allows setting of the pri‐
ority but will not affect thread scheduling behavior. Function
thr_stksegment(3scl) always returns EAGAIN
In summary, the functionality which Solaris threads has which POSIX
threads on Tru64 UNIX does not have is: Solaris allows a thread's exe‐
cution to be suspended and resumed. SCL provides this functionality:
see thr_suspend(3scl) and thr_continue(3scl). Solaris allows a thread
to join with an unspecified thread (join-any thread). SCL provides this
functionality: see thr_join(3scl). Solaris allows daemon threads to be
created. SCL provides this functionality: see thr_create(3scl). If a
threaded Solaris process calls fork(2), the new child process conatins
all the same threads as the parent. SCL does not provide this function‐
ality: the child process has only one thread.
Thread Library Components
The Solaris Thread Library comprises of: o two header files:
synch.h thread.h
which by default reside in the /usr/opt/solcomplib/include directory
o and a shared library:
libpthread.so
which by default resides in the /usr/opt/solcomplib/shlib directory.
Building And Running Solaris Thread Programs
To build and run a C program against the Solaris Thread Library, the
following points should be considered: compile the program with the
-pthread compiler option use the compiler qualifier -I/usr/opt/solcom‐
plib/include to tell the compiler where to find the Solaris header-
files use the link-editor options -L/usr/opt/solcomplib/shlib -lthread
to link against the Solaris Thread Library set the environment vari‐
ables NLSPATH and LD_LIBRARY_PATH so that at run-time the message-cata‐
log and thread library can be located.
E.g. to compile, link and run the Solaris thread program stl_example.c
(using the C shell to set environment variables): # cc -pthread
-I/usr/opt/solcomplib/include stl_example.c -L/usr/opt/solcom‐
plib/shlib -lthread-o stl_example # setenv NLSPATH /usr/opt/solcom‐
plib/lib/nls/msg/%N # setenv LD_LIBRARY_PATH /usr/opt/solcomplib/shlib
# stl_example
STL Environment Variables
There are a number of environment variables which affect the run-time
behaviour of the Solaris thread library. These are:
Name of the log-file to be used by the Solaris Compatibility Libraries
for logging error messages. See scl_error_log(4scl) for more informa‐
tion. Signal number to be used by thr_suspend(3scl). Default is 30
(SIGUSR1). Signal number to be used by thr_continue(3scl). Default is
31 (SIGUSR2). Action to be taken when an attempt is made to create a
system-wide (USYNC_PROCESS) synchronization object (mutex, condition
variable or read/write lock), which this implementation does not sup‐
port. See cond_init(3scl), mutex_init(3scl), and rwlock_init(3scl).
Possible values are:
Log an error message and abort the process (this is the default action)
Returns EINVAL error-status Initializes object as type USYNC_THREAD
instead
an integer, which if 0 specifies that daemon threads should not be
implicitly created as detached. Any other value or if undefined causes
daemon threads to be created as detached. See thr_join(3scl).
RELATED INFORMATION
Functions: pthread_intro(3), scl_intro(3scl)
Manuals: Solaris Compatibility Libraries User's Guide
scl_thread_intro(3scl)