Google SOC project POSIXFIFOs

Wei Shen cquark at gmail.com
Fri Mar 21 10:10:48 UTC 2008


Hi,

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
routines.
3) Some kinds of atomic mechanism is needed for buffer control variable
access.
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.

Regards,
Wei Shen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20080321/968243bf/attachment-0001.html>


More information about the users mailing list