MT Interface Safety Levels
The man pages for functions
and interfaces indicate how well the function or interface supports threads.
The ATTRIBUTES section of each man page lists the MT-Level attribute, which
is set to one of the safety level categories listed in Table 7–1. These categories are
explained more fully in the attributes(5) man page.
If a man page does not state explicitly that a function is MT-Safe,
you must assume that the function is unsafe.
Table 7-1 Interface Safety Levels
| |
Safe
| This code can be called from a multithreaded application
|
Safe with exceptions
| See the NOTES sections of the man page for a description of the exceptions.
|
Unsafe
| This interface is not safe to use with multithreaded applications unless
the application arranges for only one thread at a time to execute within the
library.
|
MT-Safe
| This interface is fully prepared for multithreaded access. The interface
is both safe and supports some concurrency.
|
MT-Safe with exceptions
| See the NOTES sections of the man page for a description of the exceptions.
|
Async-Signal-Safe
|
|
Fork1–Safe
| This interface releases locks it has held whenever
Oracle Solaris fork1(2) or POSIX fork(2) is called.
|
|
Some functions have purposely not been made safe for the following reasons.
The interface made MT-Safe would have negatively affected
the performance of single-threaded applications.
The library has an unsafe interface. For example, a function might
return a pointer to a buffer in the stack. You can use re-entrant counterparts
for some of these functions. The re-entrant function name is the original
function name with “_r” appended.
Note - The only way to be certain that a function with a name not ending
in “_r” is MT-Safe is to check the function's
manual page. Use of a function identified as not MT-Safe must be protected
by a synchronizing device or by restriction to the initial thread.