Re: Buffering in pipes
From: Haakon Riiser (hakonrk_at_fys.uio.no)
Date: 11/12/03
- Next message: j kopek: "problem with getch()"
- Previous message: Derk Gwen: "Re: Buffering in pipes"
- In reply to: Derk Gwen: "Re: Buffering in pipes"
- Next in thread: Derk Gwen: "Re: Buffering in pipes"
- Reply: Derk Gwen: "Re: Buffering in pipes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 12 Nov 2003 14:04:15 GMT
[Derk Gwen]
> Haakon Riiser <hakonrk@fys.uio.no> wrote:
> # I have a pair of programs that communicate using standard pipes
> # (i.e., pipe(2)). The process with the write-end of the pipe
> # downloads data from the net (or a local file), and dumps it into
> # the pipe. The read-end gets data from this pipe, never caring
> # where it came from, and feeds it into an MPEG decoder.
>
> I suppose if you flagellate your box and yourself long enough, you can get
> pipes to do what you want. Or else you can try a more appropriate technique.
> With IPC messages you have more direct control over what is in the queue,
> you can fake up asynchronous signals, and you can put your process to sleep
> on queue empty. You can set up a shared memory for the data transfer and use
> the queue to transfer available buffer addresses and control messages.
> You can also use semaphores to manage shared buffers.
Yes, I know all about the alternatives, but if there were an
easy way to discard buffered data from pipes, they would give
me everything I need right out of the box. I'd like to avoid
reinventing pipes using other forms of IPC, if at all possible.
(Actually, I have already done that once, but that implementation
was designed for IPC between threads, so it won't work here.
And it wasn't exactly painless to write either -- there's little I
hate more than race conditions.)
Anyway, I'm fairly sure that named pipes (using close/open to
flush old data) would work but, as I said, I am curious as to
_why_ my current solution doesn't work. How come there's still
leftovers in the pipe after read() returns EAGAIN?
-- Haakon
- Next message: j kopek: "problem with getch()"
- Previous message: Derk Gwen: "Re: Buffering in pipes"
- In reply to: Derk Gwen: "Re: Buffering in pipes"
- Next in thread: Derk Gwen: "Re: Buffering in pipes"
- Reply: Derk Gwen: "Re: Buffering in pipes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|