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-24
Careful Programming With Static Servers
For example, the World Wide Web (WWW) server program httpd is implemented in
UNIX systems as a dynamic server. Each time a new request is received by the WWW
server, a new process is created by the fork() function to handle the incoming
request. When the handling of the request is complete, the process terminates. The
WWW server handles multiple requests in parallel by creating a new process to handle
each request to completion.
In the OSS environment, the iTP Secure WebServer program httpd is implemented
as a set of static servers. That is, the iTP Secure WebServer creates a number of
static servers, which read their requests from a queue file written by the iTP Secure
WebServer, which, in turn, listens for incoming requests from the network. Each static
server waits for another request—after it has handled a current request. This strategy
enables requests to be processed without the additional overhead of process creation
and termination. (Refer to the iTP Secure WebServer System Administrator’s Guide for
more information about the iTP Secure WebServer; refer to the httpd(8) reference
page online on systems that have the iTP Secure WebServer installed for more
information about httpd in the OSS environment.)
A demon (or daemon) is a system process, usually a server process, started at
system initialization. Examples of demons are an application process that is always
running or a process that executes under control of the timing subsystem. Demons are
often listener processes, handling remote requests and supporting user-level functions
in a network; they can start static servers and dynamic servers.
The Guardian LISTNER process and the UNIX inetd process are both examples of
demon processes. The OSS version of inetd is not a true demon, because it is not
started at system initialization; OSS inetd is a static super server, as described under
Guardian LISTNER Versus UNIX and OSS inetd on page 6-25.
Careful Programming With Static Servers
When dynamic servers are used, a programmer can be careless about how memory is
deallocated and files are closed after a request is handled because dynamic servers
are terminated after handling the request. Because static servers are not terminated
after a request is handled, more careful accounting for resource use by the server
program is required.
If memory is not released after its use (creating memory leaks) a process can grow to
be very large. If files are not closed after their use, the number of files kept open by a
process will increase until some limit is hit, and the process might abort. You should be
careful when working with static servers so they are serially reusable in the OSS
environment. Be sure to include statements in your programs to deallocate memory
and close files.
Static Servers and Load Balancing
Using the NonStop architecture, you can set up many static servers. For example, for
eight processors, you can have eight different static servers, distributing requests
across different processors. These servers can all be processing requests in parallel,