Download Expipe User Guide
Transcript
Getting Started Writing Program (WRPROG) OPEN OUTPUT PIPE1 PIPE2. PERFORM WRIT1 nn TIMES. CLOSE PIPE1 PIPE2. WRIT1. WRITE REC1. <––––(1) WRITE REC2. <––––(2) Reading Program (RPROG) OPEN INPUT PIPE1 PIPE2. PERFORM READ1 UNTIL cond_1. : PERFORM READ2 UNTIL cond_2. : READ1. READ PIPE1 AT END para-1. <––––(3) READ PIPE2 AT END para-2. <––––(4) READ2. In this example, the reading program RPROG has a cycle to access the pipe PIPE2, which is quite different from that of the writing program WPROG. That is, RPROG starts reading PIPE2 after it finishes reading PIPE1; whereas, WPROG writes to PIPE1 and PIPE2 concurrently. Therefore, it is possible for the FIFO buffer for PIPE2 to become full before control is passed to the READ statement (4), which results in both WPROG and RPROG becoming deadlocked. In order to avoid a deadlock situation, the writing program (WPROG) must be modified so that it can have the cycle to access PIPE1 and PIPE2 similar to that of the reading program (RPROG). The modified writing program is shown in the following example. Modified Writing Program (WPROG) OPEN OUTPUT PIPE1 PIPE2. PERFORM WRIT1 nn TIMES. CLOSE PIPE1. PERFORM WRIT2 nn TIMES. CLOSE PIPE2. WRIT1. WRITE REC1. WRIT2. WRITE REC2. 7846 7024–000 <––––(1) <––––(2) 2–5