Async-Signal-Safe Functions
Functions that can safely be called from signal handlers are Async-Signal-Safe. The POSIX standard defines and lists Async-Signal-Safe
functions (IEEE Std 1003.1-1990, 3.3.1.3 (3)(f), page 55). In addition to
the POSIX Async-Signal-Safe functions, these three functions from the Solaris
threads library are also Async- Signal-Safe.
sema_post(3THR)
thr_sigsetmask(3THR), similar to pthread_sigmask(3THR)
thr_kill(3THR), similar to pthread_kill(3THR)
MT Safety Levels for Libraries
All routines that can potentially be called
by a thread from a multithreaded program should be MT-Safe.
This means that two or more activations of a routine must be able to correctly execute concurrently. So, every library interface that
a multithreaded program uses must be MT-Safe.
Not all libraries are now MT-Safe. The commonly used libraries that
are MT-Safe are listed in Table 6-3.
Additional libraries will eventually be modified to be MT-Safe.
Table 6-3 Some MT-Safe Libraries
Library | Comments |
lib/libc | Interfaces that are not safe have thread-safe interfaces of the form *_r (often with different semantics) |
lib/libdl_stubs | To support static switch compiling |
lib/libintl | Internationalization
library |
lib/libm | Math library compliant
with System V Interface Definition, Edition 3, X/Open and ANSI C |
lib/libmalloc | Space-efficient memory allocation library; see malloc(3X) |
lib/libmapmalloc | Alternative mmap(2)-based memory allocation library; see mapmalloc(3X) |
lib/libnsl | The TLI interface, XDR, RPC clients
and servers, netdir, netselect and getXXbyYY interfaces are not safe, but have thread-safe interfaces of the form getXXbyYY_r |
lib/libresolv | Thread-specific errno support |
lib/libsocket | Socket library for making network connections |
lib/libw | Wide character and wide string functions for supporting
multibyte locales |
lib/straddr | Network name-to-address translation library |
lib/libX11 | X11 Windows library
routines |
lib/libC | C++ runtime shared objects |
Unsafe Libraries
Routines in libraries that are not guaranteed to be MT-Safe can safely
be called by multithreaded programs only when such calls are single threaded.