27.04.2013 Views

MVS Jan 2005.p65 - CBT Tape

MVS Jan 2005.p65 - CBT Tape

MVS Jan 2005.p65 - CBT Tape

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

something like:<br />

pid = fork();<br />

if (pid < Ø)<br />

{<br />

printf("fork() failed – errno=%d\n",errno);<br />

return(-1);<br />

}<br />

else if (pid > Ø)<br />

{<br />

printf("Executing in the parent process. Child PID is %d\n",pid);<br />

}<br />

else<br />

{<br />

printf("Executing in the child process.\n");<br />

}<br />

The fork() function call has the following drawbacks:<br />

It can be used only in programs running in problem state,<br />

key 8.<br />

The child process runs in a separate address space from<br />

that of the parent process.<br />

The parent process task issuing the fork() is copied into<br />

the child address space.<br />

<strong>MVS</strong> files opened in the parent process are not opened in<br />

the child process with the exception of TASKLIB, STEPLIB,<br />

and/or JOBLIB. The child process maintains the same<br />

<strong>MVS</strong> program search order as the initiating parent process,<br />

but does not maintain access to other <strong>MVS</strong> datasets<br />

allocated to the parent process.<br />

THE SPAWN() FUNCTION<br />

A second multi-tasking method is the spawn() function. Here<br />

are some of its functional highlights:<br />

The child process will inherit the parent process’s TASKLIB,<br />

STEPLIB, and JOBLIB allocations unless a STEPLIB<br />

environment variable is used for the spawned process.<br />

The setting of the _BPX_SHAREAS environment variable<br />

28 © 2005. Xephon USA telephone (214) 340 5690, fax (214) 341 7081.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!