help-octave
[Top][All Lists]
Advanced

[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: Fri, 28 Aug 1998 15:55:45 +0200 (MET DST)

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)
     times--;
     if (fid1 < 0)
        fprintf(stderr, "Open gPROMS.pipe...");
        fid1 = fopen("../gproms/gPROMS.pipe", "r");
        fprintf(stderr, "done.\n");
     end
     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...");
     sleep(15);
     fprintf(stderr, "awaken.\n");
     if (fid2 < 0)
        fprintf(stderr, "Opening Matlab.pipe...");
        fid2 = fopen("../gproms/Matlab.pipe", "w+");
        fprintf(stderr, "done.\n");
     end
     fprintf(stderr, "About to send Wf...");
     fwrite(fid2, "4\n");
     fflush(fid2);
     fprintf(stderr, "done.\n");
endwhile

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
system?

Thanks a lot in advance.

        Marco Bravi

PS I am using Octave 2.0.13.

--
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]