[time-nuts] time-nuts Digest, Vol 66, Issue 6

Mark Sims holrum at hotmail.com
Sun Jan 3 23:55:25 UTC 2010


So what...

Actually Heather does not poll the serial port continually.   It uses the Windows interrupt driven serial I/O routines that fill a big buffer in the background.  

What is does do is continually ask "give me a serial port character if you have one".  It makes no practical difference performance wise whether this is done at the operating system level or by a local routine that fetches characters out of a larger buffer.  Either way you ultimately wind up calling a "give me the next serial port character" routine.   

The serial port code is structured along the lines of "least common denominator."   It makes the minimal use of operating system dependent features and should be very easy to port to other systems.  The serial I/O routines that it uses are basically 1) Is there a character available?  2) Get me that character  3) Send this character out.  (and remember that at its core,  Heather is a DOS program)

As far as the time slicing goes,  the code is continually doing Sleep(0) calls.  These give the time slice back to Windows.    You can't get much more multitask friendly than that.

If Windows has nothing better to do,  it gives the time back to Heather (which if there is nothing else going on,  does another Sleep(0) (or Sleep(#) if /tw=# is given on the command line).  The idle time would otherwise be spent in the Windows idle loop...   either way,  the idle time gets wasted somewhere.
----------------------
It polls the serial port continually :-( 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/


More information about the time-nuts mailing list