Open System Services Programmer's Guide
to handle signals, converting it to an application that uses the PUT Model library might require
additional logic to handle thread-specific signals.
Use of Process Resources
There are many differences in the internal logic of the public libraries that provide run-time services.
The resultant different (potentially dramatically different) patterns of usage of process resources
can have an impact ranging from minor to severe. In particular, implementations of various functions
in public libraries can consume larger amounts of memory when called from an application that
uses the PUT Model library. For example, the function getservent() returns the address of a
struct servent whose content is managed by the INET public library. For an application that
uses the SPT library, every call modifies and returns the address of the same data space. For
application that uses the PUT Model library, the library allocates and manipulates a separate
struct servent data space for each thread. The cumulative impact of all increases in memory
allocated could affect the performance of, or in a severe case lead to the failure of, a successful
application that was converted from using the SPT library to using the PUT Model library.
Threaded Application Programming
Keeping Application Design Simple
Because of the inherent complexity of multithreaded programming, application designers should
follow these recommendations:
• Write programs with a single application thread when possible.
• Keep multiple application threads independent of each other when possible. If this is not
possible, keep the interdependencies to a minimum.
Threading Considerations
Application designers should be aware of the following general threading considerations when
developing a the PUT Model library application:
• “Sharing Process Resources” (page 428)
• “Using Standard Libraries” (page 428)
• “Addressing the Thread Stack” (page 429)
• “Making Process-Blocking Calls” (page 430)
• “Using Nowait Input or Output” (page 430)
• “Yielding Control” (page 430)
• “Using Signals” (page 386)
• “Spawning a New Process” (page 430)
• “Isolating Faults” (page 430)
Sharing Process Resources
Access by threads to shared process resources such as global data, the heap, and files must be
synchronized using mutexes and condition variables. Table 66 (page 383) lists global and private
process resources.
Using Standard Libraries
No Need for Jacket Routines or Special Header Files
On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUS, standard
library functions do not require jacket routines, special header files, or other modifications to make
them thread-safe or reentrant.
428 Using the POSIX User Thread (PUT) Model Library










