Open System Services Porting Guide (G06.24+, H06.03+)
Table Of Contents
- What’s New in This Manual
- About This Manual
- 1 Introduction to Porting
- 2 The Development Environment
- 3 Useful Porting Tools
- 4 Interoperating Between User Environments
- Purpose of Interoperability
- The OSS User Environment
- OSS Commands for the Guardian User
- Guardian Commands for the UNIX User
- OSS Pathname and Guardian Filename Conversions
- Running the OSS Shell and Commands From TACL
- Running Guardian Commands From the OSS Shell
- Running OSS Processes With Guardian Attributes
- Using OSS Commands to Manage Guardian Objects
- 5 Interoperating Between Programming Environments
- 6 OSS Porting Considerations
- 7 Porting UNIX Applications to the OSS Environment
- 8 Migrating Guardian Applications to the OSS Environment
- General Migration Guidelines
- C Compiler Issues for Guardian Programs
- Using New and Extended Guardian Procedures
- Using OSS Functions in a Guardian Program
- Interoperating With OSS Programs
- Starting an OSS Program From the Guardian Environment
- C Compiler Considerations for OSS Programs
- Porting a Guardian Program to the OSS Environment
- How Arguments Are Passed to the C or C++ Program
- Differences in the Two Run-Time Environments
- Which Run-Time Routines Are Available
- Use of Common Run-Time Environment (CRE) Functions
- Replacing Guardian Procedure Calls With Equivalent OSS Functions
- Which IPC Mechanisms Can Be Used
- Interactions Between Guardian and OSS Functions
- 9 Porting From Specific UNIX Systems
- 10 Native Migration Overview
- 11 Porting or Migrating Sockets Applications
- 12 Porting Threaded Applications
- A Equivalent OSS and UNIX Commands for Guardian Users
- B Equivalent Guardian Commands for OSS and UNIX Users
- C Equivalent Inspect Debugging Commands for dbx Commands
- D Equivalent Native Inspect Debugging Commands for dbx Commands
- E Standard POSIX Threads Functions: Differences Between the Previous and Current Standards
- Glossary
- Index
OSS Porting Considerations
Open System Services Porting Guide—520573-006
6-10
Using Semaphores
In the OSS environment, you usually do not have to be aware of the type of memory a
program is using, unless your programs use Guardian procedures to share memory
with other processes. OSS processes can use OSS functions and Guardian
procedures to share memory with other OSS processes. To share memory with
Guardian processes, OSS processes must use Guardian procedures.
OSS functions allow OSS processes to share flat extended data segments. Guardian
procedures allow processes to share both flat and selected extended data segments.
For more information on managing memory in the OSS environment, refer to the Open
System Services Programmer’s Guide.
Using Semaphores
A semaphore is a counter used to provide access to a shared data object for multiple
processors. Semaphores are an optional feature of the XPG4 specifications. OSS
supports semaphores for single-processor operations, and programs can use either
XPG4 counting or Guardian binary semaphores.
The use of a semaphore synchronizes the access of multiple processes to a shared
resource. Semaphores are created and controlled with the semctl(), semget(), or
semop() function calls. OSS semaphores can be listed and deleted using the ipcs
and ipcrm utilities (refer to the semctl(2), semget(2), and semop(2) reference
pages either online or in the Open System Services System Calls Reference Manual
and to the ipcs(1) and ipcrm(1) reference pages either online or in the Open
System Services Shell and Utilities Reference Manual for more information).
Using the $RECEIVE File
The Guardian $RECEIVE mechanism is an interprocess communication mechanism
that can be used by OSS processes but makes them nonportable. Refer to Using
PROCESS_SPAWN_ on page 6-15, Starting a Guardian Server Process on page 6-26,
$RECEIVE on page 8-18, and to the Open System Services Sockets Programmer’s
Guide for more information.
Memory Model Considerations
For the TNS/R and TNS/E native environments and the G-series TNS environment, the
HP C compiler supports the large-memory model and the 32-bit (or WIDE) data model
for OSS programs. These models support 32-bit pointers and the 32-bit size of type
int. (The HP C compiler does not support the small-memory model or the 16-bit data
model for OSS programs.)
This subsection introduces the memory model and data model for OSS programs and
discusses allocating and deallocating memory when working with OSS programs or
porting applications to OSS environment. Refer to the C/C++ Programmer’s Guide for
details on the memory model in the Guardian environment for native and TNS
environments.