[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FIFO read by Octave does not block as desired

From: Marco Bravi
Subject: FIFO read by Octave does not block as desired
Date: Sun, 19 Jul 1998 23:19:32 +0200 (MEST)

Dear Octave users,

        I would like to use Octave as the control environment for a
simulation environment, and the two should communicate over two FIFOs.

I am experiencing a misbehaviour of this type: once the input FIFO has
been read once (blocking read, as expected), all subsequent reads return
immediately, even if the other program is not blocked in the corresponding
write. No data is actually input by this read.

This is the infinite loop I use on the Octave part:

fid1 = -1;
fid2 = -1;

times = 10;

while (times)
     if (fid1 < 0)
        fprintf(stderr, "Open gPROMS.pipe...");
        fid1 = fopen("../gproms/gPROMS.pipe", "r");
        fprintf(stderr, "done.\n");
     fprintf(stderr, "I am about to read...");
     [a, b, c, d, e, f] = fscanf(fid1, "%g %g %g %g %g %g\n", "C")
     fprintf(stderr, "done.\n");
     fprintf(stderr, "Going to sleep...");
     fprintf(stderr, "awaken.\n");
     if (fid2 < 0)
        fprintf(stderr, "Opening Matlab.pipe...");
        fid2 = fopen("../gproms/Matlab.pipe", "w+");
        fprintf(stderr, "done.\n");
     fprintf(stderr, "About to send Wf...");
     fwrite(fid2, "4\n");
     fprintf(stderr, "done.\n");

The other side has been implemented in several ways. For test purposes, a
small C program using stdin/stdout and talking to the FIFOS is what I use
for debugging all my programs uising FIFOS.

What's most puzzling, is that once the first read has been performed
correctly (i. e., with blocking behaviour) the fscanf call returns *even
if the other program is terminated*, i. e., no other program is writing
the FIFO. This appears rather strange to me since I did not open the FIFO
for read/write (as it is often seen in order to avoid blocking on open).

Could you please suggest an explanation for this and a workaround for
correctly syncyng the two concurrent processes with this FIFO read/write

Thanks a lot in advance.

        Marco Bravi

Marco Bravi                     address@hidden
Dip. Ing. Chimica               tel. +39-6-44585587 / 612
v. Eudossiana, 18               fax  +39-6-4827453
I-00184 Roma (Italy)            

reply via email to

[Prev in Thread] Current Thread [Next in Thread]