|Skip Navigation Links|
|Exit Print View|
|Multithreaded Programming Guide Oracle Solaris 11 Express 11/10|
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
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.
For most functions with unsafe interfaces, an MT-Safe version of the routine exists. The name of the MT-Safe routine is the name of the Unsafe routine with “_r” appended. For example, the MT-Safe version of asctime() is asctime_r(). The Table 7-2 “_r” routines are supplied in the Solaris environment.
Table 7-2 Reentrant Functions