TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Phil Crown
from: Peter Fitzsimmons
date: 1997-01-09 02:56:08
subject: DosRead blocking

JRC> more efficient to buffer
 JRC> the comm port with a thread in the program, or 
 JRC> not to worry with it. 
 JRC> I've been turning that one around in my head for 
 JRC> a couple of days and
 JRC> I can't see where the overhead would be worth it ...


Doing i/o to different devices, each in their own thread,  allows OS/2 to
overlap i/o;  definitely worth the effort for any type of program.


 PC> If its a PM program I would use a thread to avoid blocking the message
 PC> queue (main) thread for too long.

 PC> Also by using a secondary thread you can adjust the priority.  In my app
 PC> the thread that reads the com port runs at PRTYC_TIMECRITICAL and all
 PC> the other threads run at PRTYC_REGULAR.

This may actually be counter productive;  by servicing the device driver
too often,  you will call DosRead() more often (then if your thread was
running at a lower priority).  The DosRead() calls will transfer fewer
bytes with each call (perhaps as low as 1 to 10 bytes).  Since the overhead
of calling DosRead() is _huge_,  you want to call it as few times as
possible,  and get as many bytes back with each call (this is why
"Wait for something" read timeout processing is so cool).

By lowering the priority,  and DosReading, say, 100+ bytes at a time (and
10 times fewer DosRead calls),  your throughput will actually increase (and
your cpu load will lower drastically).

I have written a lot of OS/2 comm software.  None of them use time
critical.  What I usually do is run all threads at "regular", and
allow an option to run at "foreground server" for taxed systems; 
for the later,  however,  I raise the priority of all of the threads,  not
just the comm thread,  so that the balance I described above is maintained.


--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)
SEEN-BY: 50/99 54/99 270/101 620/243 625/0 160 640/201 711/401 409 410 413
SEEN-BY: 711/430 808 809 934 955 712/311 407 505 506 517 623 624 704 841
SEEN-BY: 713/317 800/1
@PATH: 259/414 99 2424/38 11 10 396/1 270/101 712/624 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.