docs.intersystems.com
InterSystems IRIS Data Platform 2019.2  /  I/O Device Guide  /  Local Interprocess Communication

I/O Device Guide
Communication Between InterSystems IRIS Processes
Previous section          
InterSystems: The power behind what matters   
Search:  


Communication Between InterSystems IRIS Processes
Interjob communication (IJC) devices are a set of special device numbers that let you transfer information between two or more InterSystems IRIS processes. The processes can be either jobbed processes or interactive processes.
IJC devices work in pairs. You can have up to 256 IJC device pairs. You use even-numbered devices, called receivers, to read data. You use odd-numbered devices, called transmitters, to write data. Attempts to read from a transmitter or write to a receiver result in a <NODEV> error.
You issue I/O commands to IJC devices, just as to any other device. After issuing OPEN and USE commands to the device, a process can issue:
Only one process at a time can have a device open.
Pairs are based on relative order as mapped in the InterSystems IRIS Device Table, which you can view and edit using the configuration options of the Management Portal.
Each pair of devices is associated with an IJC memory buffer. When a process issues a WRITE command to any odd-numbered IJC device, InterSystems IRIS writes the data into the buffer for that device pair. When another process issues a READ command to the even-numbered device from that pair, InterSystems IRIS reads the data from the same buffer.
Written data is buffered in memory in first-in, first-out fashion. If a READ occurs while the device is empty, the process that issued it suspends until another process issues a corresponding WRITE. A WRITE that occurs while the buffer is full suspends until another process reads from that buffer.
After you write a message to the buffer, it remains there until it is read, even if you close the transmitter. Several users can issue OPEN, USE, WRITE, and CLOSE commands to a transmitter, one at a time in turn. Subsequent READ commands get all of the messages in the order in which they were written.
Specifying Memory Buffers for Interjob Communication Devices
The system manager can configure the IJC buffers using the Management Portal. Select System Administration, Configuration, Additional Settings, Advanced Memory. The two parameters that can be set are:
Each IJC device corresponds to one IJC buffer of the size specified in ijcbuff. You can write a message of length ijcbuff minus 1.
Disabling Interjob Communication Buffers
If you will not be using IJC devices, you can set the maximum number of IJC devices (ijcnum) to 0 to avoid tying up memory.
Interjob Communication Device Numbers
Interjob communication devices are automatically defined numbered by InterSystems IRIS. Their actual identification numbers depends on the maximum number of IJC buffers configured on the system.
The table below gives the ranges of IJC device numbers that are available on your system, depending on the number of IJC buffers that you have allocated.
For example, if you allocate 8 IJC buffers, then device numbers from 224 through 239 are defined on the system (even numbers for READ devices and odd numbers for WRITE devices).
As another example, if you allocate 94 IJC buffers, then the following range of device numbers are defined: 224 through 255, 64 through 199, 4 through 19, and 2048 through 2051. You can use any even/odd number pairs with OPEN, USE, READ, WRITE, and CLOSE commands.
IJC Device Numbers
Buffers Allocated READ Device # WRITE Device #
1 224 225
2 226 227
3 228 229
... ...  
15 252 253
16 254 255
17 64 65
18 66 67
... ... ...
83 196 197
84 198 199
85 4 5
86 6 7
87 8 9
88 10 11
89 12 13
90 14 15
91 16 17
92 18 19
93 2048 2049
94 2050 2051
95 2052 2053
... ... ...
254 2370 2371
255 2372 2373
256 2374 2375
I/O Commands for IJC Devices
You use all of the standard I/O commands with IJC devices: OPEN, USE, READ, WRITE, and CLOSE.
OPEN Command
The OPEN command reserves interjob communication devices for your use.
Syntax
OPEN device::timeout
where:
device A device number from the table above. OPEN an even-numbered device to issue READ commands. OPEN an odd-numbered device to issue WRITE commands. For two processes to communicate, they must open a set of device pairs.
timeout Optional — A positive integer whose value in seconds is the longest time InterSystems IRIS waits for an OPEN to finish. If you specify 0, the OPEN returns control to the process immediately.
This example shows how two processes communicate by opening separate devices for reading and writing:
Process A                          Process B 
OPEN 227 USE 227 WRITE "MSG_1"
WRITE "MSG_2"                       OPEN 226 USE 226 READ X
CLOSE 227                           CLOSE 226
OPEN 224 USE 224 READ X             WRITE X
CLOSE 224                           MSG_1
WRITE X                             .
MSG_3                               .
                                    .
                                    OPEN 225 USE 225 WRITE "MSG_3" 
                                    CLOSE 225
Process A begins by opening device 227 and writing MSG_1 to it. InterSystems IRIS writes this message into the buffer shared by devices 226 and 227. Process A then writes a second message to the same buffer. Now Process B opens companion device 226 and reads the first message (MSG_1) from the buffer.
Now Process A wants to read a message, so it must open a different device, 224. Because the buffer for this device and its companion, 225, is currently empty, Process A waits until Process B opens device 225 and writes MSG_3 to it. After InterSystems IRIS places this message in the buffer shared by devices 224 and 225, the READ command to device 224 succeeds.


Previous section          
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-13 06:50:57