home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
sigm
/
vol247
/
examples.lbr
/
PCLI.DQC
/
pcli.doc
Wrap
Text File
|
1986-02-27
|
3KB
|
65 lines
Documentation For PCLI.A86 and CCLI.A86 Files
Producer/Consumer Example
The programs PCLI.A86 and CCLI.A86 work together to demonstrate
the basic Producer/Consumer situation under Concurrent CP/M.
PCLI.A86 is the producer part of the process, and CCLI.A86 is the
consumer part. Both files require RASM86 and LINK86.
This example shows the simplist method to have to concurrently
running processes comunicate. In this model, the producer reads
data from a disk file and sends the data to a queue. Meanwhile,
the consumer reads data from the queue and prints it on the
printer. This concept can be enhanced to create a simple print
spooler.
When the producer is executed, it first sets up a queue for
inter-process communication, and then initiates the second
process (the consumer) using the P_CLI function. This function
takes data from a Command Line Buffer and executes it as it were
a command line typed at the console. If this command line
contains a valid command, the progrm it loads will start
execution in background while the program that called the P_CLI
function continues execution in the foreground. The main process
(the producer) then enters a loop that reads a record from a disk
file and writes the record to the queue. When the end of file is
reached, it writes a specially formatted end-of-transmission
message to the queue.
The consumer must only be started by the producer and not
executed from the console. When this program is initiated by the
producer, it opens the queue that the producer created, and then
enters a loop that continually reads records for the queue and
prints them on the printer. When the end-of-transmission message
is read, it delets the queue and terminates. The listing
includes a line of code that causes the process to detach from
the console after it has created the queue and opened the file
successfully. If this code is included, this example could be
used as a primitive "Print Spooler".
The queue that is used by these two processes to communicate had
messages that are 81h bytes long. The first byte is used to
determine whether the message contains a valid data record or
whether it is a end-of-transmission message. The rest of the
message (128 bytes) will contain a valid data record when the
message is not a end-of-transmission message. If the message
contains a valid data record, the first byte will contain the
value ffh. If the message is the end-of-transmission message the
first byte contains the value 00h, and the rest of the message is
ignored.
Note that the program names PCLI and CCLI can be changed to
whatever you wish, but if you do change CCLI to something else,
you also must change the command in the Command Line Buffer area
in the data segment of the first program (PCLI). If you wish to
expand the number of messages the queue can hold so that the
program will work as a print spooler more effectively, make sure
that you don't overflow the Free Queue Buffer space. You can
find out what the free queue buffer space is by executing the
SYSTAT utility and giving the O option. The buffer space under
Concurrent PC-DOS is 0500h bytes, so the maximum number of 129
byte messages we can have under this O/S is 9.