Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
Migrating Guardian Applications to the OSS
Environment
Open System Services Porting Guide520573-006
8-19
Using Files
Using Files
Guardian and OSS processes can share a file. The file can be an OSS file or a
Guardian file and can be accessed through Guardian procedures or C functions in a
Guardian program. In an OSS program, the file can be accessed using a C run-time
function. If one process completes the writing of a file before the other process reads
the file, no synchronization problems occur. However, if the Guardian and OSS
process wish to share the file at the same time, a synchronization method must be
used. Guardian file locking for Guardian files and OSS file locking for OSS files can be
used to synchronize access. Guardian semaphores are another mechanism that can
be used, because Guardian semaphores can be invoked in both Guardian and OSS
programs. See the Guardian Programmer’s Guide for further information on
communicating using files.
Using Queue Files
The use of queue files is a particularly efficient mechanism for communication between
OSS programs and Guardian programs. A queue file is a special file that can be written
by multiple writers and read by multiple readers, in a first-in, first-out order. This is
particularly useful for the construction of parallel servers, each running in a separate
processor, reading requests from one centralized queue and servicing them in the
order that the requests are written to the queue. The Guardian DP queue file provides
the synchronization mechanism itself. Along with the performance and ease of
programming advantages comes the disadvantages that they lack any management
and fault tolerant features.
Using Shared Memory
In the Guardian environment, both flat and selectable memory segments can be
created and shared. Guardian processes can share and synchronize access to
memory using Guardian shared memory and semaphore functions. Guardian
processes cannot use OSS functions to share and synchronize access to memory with
other Guardian or OSS processes. OSS processes can share and synchronize access
to memory with other OSS processes using OSS shared memory and semaphore
functions.
A Guardian process can only share and synchronize access to memory with an OSS
process by using the Guardian functions. Only flat segments can be shared between
Guardian and OSS processes. The distinction between flat and selectable segments,
and how to use these shared memory segments, is discussed in detail in the Open
System Services Programmer’s Guide. Using shared memory is an efficient IPC
mechanism that can be used when large amounts of data need to be shared between
an OSS process and a Guardian process running on the same processor.
Using Semaphores
Guardian semaphores are binary semaphores available to Guardian and OSS
programs. OSS semaphores are counting semaphores and are oriented towards