This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Performance patch to termios code



The termios code only reads one char at a time.
This creates poor performance in many cases and is
easy to fix. The patch below causes read() to
keep reading so long as there are still characters
available that won't cause cause a block.
I belive this is the correct behavior.

best

-paul


--- termiostty.c        Thu Jan 10 17:35:07 2002
+++ termiostty.c.new    Thu Jan 10 17:34:23 2002
@@ -630,7 +630,7 @@
     cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle;
     struct termios *t = &priv->termios;
     cyg_uint32 clen;
-    cyg_uint32 size;
+    cyg_uint32 size, remaining = 0;
     Cyg_ErrNo res;
     cyg_uint8 c;
     cyg_uint8 *buf = (cyg_uint8 *)_buf;
@@ -656,6 +656,7 @@
                                  &dev_buf_conf, &dbc_len );
         CYG_ASSERT( res == ENOERR, "Query buffer status failed!" );
         *len = *len < dev_buf_conf.rx_count ? *len : dev_buf_conf.rx_count;
+       remaining = dev_buf_conf.rx_count;
     } // if
 
     while (!returnnow && size < *len) {
@@ -666,6 +667,7 @@
             *len = size;
             return res;
         }
+       remaining--;
 
         // lock to prevent termios getting corrupted while we read from it
         cyg_drv_mutex_lock( &priv->lock );
@@ -749,8 +751,9 @@
                 returnnow = true; // FIXME: true even for INLCR?
             } // else if
         } else { // non-canonical mode
-            if ( size+1 >= t->c_cc[ VMIN ] )
+            if ( size+1 >= t->c_cc[ VMIN ] && !remaining) {
                 returnnow = true;
+           }
         } // else
 
 #ifdef CYGSEM_IO_SERIAL_TERMIOS_USE_SIGNALS


---------------------------------------------
This message was sent using World Mail.
http://www.worldonline.co.za



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]