COBOL Manual for TNS and TNS/R Programs
Process Initiation, Communication, and
Management
HP COBOL Manual for TNS and TNS/R Programs—522555-006
31-13
Example of Simple Interprocess Communication
The report in Example 31-6 shows that the process-pair named $Z000 consists of a
primary process running in processor module 00 with the process identification number
(PIN) 022 and a backup process running in processor 01 with the PIN 021. The
processor and PIN of the process that started $Z000 (its ancestor) is 00,021. Notice
that not all processes are executing as process pairs—$DM00 and $DM01 (parts of
the Inspect symbolic debugger) are running as single processes.
Every disk volume name, device name, spooler collector name, and so on, begins with
a dollar sign. Each time you read from or write to one of them, you are reading from or
writing to the process controlling that entity.
Example of Simple Interprocess Communication
This example illustrates the principles of interprocess communication using named
processes and $RECEIVE (see Figure 31-4).
The program PITCHER accepts a line of text from its home terminal and transmits it to
the process $CATCH (the program named CATCHER). When it receives a line
beginning with the value “END,” PITCHER terminates after transmitting the line.
CATCHER displays each line on its home terminal. When the process that opened
CATCHER terminates, an HP COBOL run-time routine translates the closure as an
end of file (EOF) on $RECEIVE. The AT END phrase of the READ statement passes
control around the DISPLAY statement, the PERFORM terminates because its UNTIL
phrase is satisfied, and CATCHER terminates. (Use of an empty declarative would
eliminate the need for the END-TRANS paragraph and the AT END GO TO construct.)
The bold text in Example 31-7 is significant. Note that, in PITCHER, the file for
CATCHER is opened for I-O even though it is being used only for output. If you open a
process with the OUTPUT or EXTEND attribute, HP COBOL handles the process as a
printer device and tries to advance it to the next page—an operation that is
meaningless (and fatal) to CATCHER.
Figure 31-4. $RECEIVE From PITCHER to CATCHER
"PITCHER" $CATCH
text line
VST712.vsd