[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Google SOC project POSIXFIFOs
- Date: Fri, 21 Mar 2008 18:10:48 +0800
- From: cquark at gmail.com (Wei Shen)
- Subject: Google SOC project POSIXFIFOs
On 3/20/08, Joel Sherrill <joel.sherrill at oarcorp.com> wrote:
> Hmm... read that carefully.. it said you MIGHT be able to refactor
> the buffering code
> out of termios into a common ring buffer handler. It also said that it
> might be impossible
> because the canonical character processing might be too intertwined.
I studied the termios source code today. I think it may be diffcult to share
buffering code between termios and pipe. Reasons are listed below:
1) termios needs to process input characters one by one (in siproc). May
change, echo, or erase a charater, and check for new lines.
2) termios may send control characters during input/output processing, and
may initiate device commands.
3) One end of termios buffering is in RX/TX IRQ context, and
interrupt_disable/enable are used for synchronization.
4) termios maintains a set of buffer states to control buffering.
All these above are not needed by pipe, but mix with termios buffering code.
On the other hand, for pipe buffering implementation:
1) Two counters are needed to indicate the counts of current readers and
writers of a pipe.
2) A flag (O_NONBLOCK) should be added and checked in pipe buffer read/write
3) Some kinds of atomic mechanism is needed for buffer control variable
4) Sometimes, termios drops some charaters when the inbuffer is full.
So, even if refactering existing code is possible, it may not be worthwhile
for the complexity introduced.
Comments are solicited.
-------------- next part --------------
An HTML attachment was scrubbed...