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

Table Of Contents
OSS Porting Considerations
Open System Services Porting Guide520573-006
6-13
Using Process-Creation Calls
versions of the UNIX operating system in addition to the OSS environment. See
Predefined Preprocessor Symbols on page 7-15, which discusses conditional
compilation of system-dependent code.
Using Process-Creation Calls
This subsection discusses the OSS process-creation functions: fork(),
tdm_fork(), and the exec, tdm_execve, and tdm_spawn sets of functions. It
compares process-creation functions between UNIX and OSS environments and
discusses methods to improve performance. For detailed descriptions of each OSS
process-creation function, refer to the online reference pages or to the Open System
Services System Calls Reference Manual.
If your program uses a lot of process-creation function calls (or script files which
contain a great deal of short commands, each requiring a process creation), your
program will experience more overhead than it might experience on other UNIX
systems. This is because the process-creation overhead is higher on Open System
Services than it is on most UNIX systems. You might wish to consider redesigning your
program to make it run more efficiently.
Using fork() and the exec Set of Functions in UNIX
In UNIX environments, a process uses the fork() function call to create another
process. The process that issues fork() is known as the “parent process”; the
process created by fork() is known as the “child process.”
When you use the fork() function call, you usually call one of the exec set of
functions immediately after it. Creating processes this way is somewhat inefficient.
First, the existing process (the parent) calls the fork() function, producing a new
process (the child), which is a copy of the parent process. One of these processes
(normally, the child) then calls one of the exec set of functions. Calling one of the
exec set of functions determines what you want to run within that process and
overlays the new process with a copy of the new process image—note the redundancy
of new process creations. This redundancy is more apparent in the OSS environment,
because there is more processor cross-checking performed than done in a UNIX
environment and because calling one of the exec set of functions in the UNIX
environment does not create a new process.
Using fork() and the exec Set of Functions in OSS
In the OSS environment, you can use fork() and the exec set of functions as you
would in the UNIX environment, or you can use comparable versions of these functions
that are HP extensions: tdm_fork() and the tdm_execve set of functions. The OSS
process-creation functions are similar to their UNIX counterparts, except that creating
processes in the OSS environment also gives the processes Guardian attributes.
Because OSS processes have Guardian attributes, Guardian procedures can access,
manage, and control OSS processes.