Hi,<br><br>
<div><span class="gmail_quote"><span class="gmail_quote">On 3/20/08, <b class="gmail_sendername">Joel Sherrill</b> <<a href="mailto:joel.sherrill@oarcorp.com">joel.sherrill@oarcorp.com</a>> wrote:</span></span><span class="q"><span class="q"><br>

<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span class="q"> Hmm... read that carefully.. it said you MIGHT be able to refactor the buffering code<br>
 out of termios into a common ring buffer handler.  It also said that it might be impossible<br></span><span class="q"> because the canonical character processing might be too intertwined.</span></blockquote></span><span class="q"><span id=""></span></span></span></div>

<div>
<div> </div>
<div>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:</div></div>
<div> </div>
<div>1) termios needs to process input characters one by one (in siproc). May change, echo, or erase a charater, and check for new lines.</div>
<div>2) termios may send control characters during input/output processing, and may initiate device commands.</div>
<div>3) One end of termios buffering is in RX/TX IRQ context, and interrupt_disable/enable are used for synchronization.</div>
<div>4) termios maintains a set of buffer states to control buffering.</div>
<div> </div>
<div>All these above are not needed by pipe, but mix with termios buffering code.</div>
<div> </div>
<div>On the other hand, for pipe buffering implementation:</div>
<div>1) Two counters are needed to indicate the counts of current readers and writers of a pipe.</div>
<div>2) A flag (O_NONBLOCK) should be added and checked in pipe buffer read/write routines.</div>
<div>3) Some kinds of atomic mechanism is needed for buffer control variable access.</div>
<div>4) Sometimes, termios drops some charaters when the inbuffer is full.</div>
<div> </div>
<div>So, even if refactering existing code is possible, it may not be worthwhile for the complexity introduced.</div>
<div>Comments are solicited.</div>
<div> </div>
<div>Regards,</div>
<div>Wei Shen</div>