HP Pascal/HP-UX Release Notes Version A.10.08

Chapter 1 33
New and Changed Features
Making Thread-Safe HP Pascal/HP-UX Routines
File Control Blocks
The file control blocks themselves are not protected.
There is a control block for each opened file. Reading, writing, and other
operations on a file search the list and update the file's control block or
return information from the control block. Each control block contains its
own buffer for file reading and writing.
The file control blocks must reside in a shared data area. Because file
control blocks are accessed when the file list is traversed, the control
blocks must be accessible to all threads in the task.
Without synchronization, a control block can become corrupt. You must
synchronize threaded applications by using mutexes and condition
variables to protect files that are shared among threads. Otherwise, a file
must be accessed by only one thread. This includes the built-in files
INPUT and OUTPUT.
Refer to HP-UX Linker and Libraries Online User Guide for guidelines.
Heap Management
The heap routines NEW, DISPOSE, MARK, RELEASE, p_getheap, and
p_rtnheap (described in Chapter 6 of HP Pascal/HP-UX Programmer's
Guide) are all thread-safe. The only important consideration is that the
effects of MARK and RELEASE are shared by all threads. If one thread does
a MARK and RELEASE, it affects all threads.
Other Libraries (Trap and Unwind Libraries)
Certain Pascal constructs depend on libraries other than the Pascal
Runtime Library, in particular, the routines documented in Chapter 11 of
HP Pascal/HP-UX Programmer's Guide. These include ESCAPE,
ESCAPECODE, XARITRAP, ARITRAP, HPENBLTRAP, and XLIBTRAP.
Support for a per-thread ESCAPECODE is provided.
The four trap routines only provide the various masks and plabels on a
global basis. It is expected that these routines are called before any user
threads are created.