TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: James R. Cook
from: Peter Fitzsimmons
date: 1997-01-10 15:46:40
subject: DosRead blocking

JRC>  Hmmm.  That's an interesting spin on the problem.  I 
 JRC> hadn't though of that
 JRC>  to be honest ... :)  I've been playing with your 
 JRC> PMTERMSR.LZH file.  Clean
 JRC>  code although I don't understand a lot of it 
 JRC> (particularily the PM stuff).
 JRC>  So, in your opinion, I should have a thread that 
 JRC> deals with incoming comm
 JRC>  bytes, a thread for outgoing comm bytes, a thread 
 JRC> for disk reads, a thread
 JRC>  for disk writes

If you are reading and writing to the same disk,  using two threads for
this will not help.  Plus -- OS/2's cache (esp HPFS) supplies the threads
for for anyway.

I don't know if you need separate modem read and write threads;  it depends
on what your program does.  If it mostly receives bytes (a terminal
program) that you definitely want a separate modem read thread. If it
spends all day sending (some sort of HOST program),  you want a write
thread.  If it does a lot of both,  do both (the modem is one of the only
devices on your PC that is full duplex -- you can be both reading and
writing at the same time at the hardware level).


 JRC> serial I/O that seems a
 JRC>  bit redundant.  For my needs, I'll be reading a single byte (or maybe a
 JRC>  group of bytes) at a time.  Output I could see a 
 JRC> separate thread, but for
 JRC>  input, I could make the input non-blocking and just see if anything is
 JRC>  waiting for me and let the OS be the thread.

If this is some sort of handshake protocol,  where you get a few bytes (to
1k or so) ( and will not get anymore until you handshake),  your reasoning
is perfect;  the interal COM.SYS buffers will never overflow.

If you are also writing fairly small packets (a few K or less) as a
response to each incoming request,  you may as well skip the write thread
too -- COM.SYS's write buffer will do the work for you.

Most of my ramblings over the years, re modems and efficiency,  assume a
steady (and/or unsolicited) stream of bytes (for example zmodem).  If you
are working on some handshaking code (something like xmodem or FTP),your
code need not worry too much about efficiency.



--- 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 711/401 409 410 413 430 808
SEEN-BY: 711/809 934 955 712/311 407 505 506 517 623 624 704 841 713/317
SEEN-BY: 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™.