| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | wait-for-something |
DM>
> And where the heck were you when
> first started trying to figure out my communications routines?
DM>
Actually he was here in OS2PROG.
By my recollection Peter has been doling out the same advice on how to
write proper comms routines for at least two years. Viz. :
-----------------------------------------------------------------------
Conference: Os2prog
To: YOU Date: 11/23/1993
From: Peter Fitzsimmons Time: 3:32 am
Subj: CommProgramming
[...elided...]
- Create a W-F-S comm thread, that reads 200 bytes at a time (an
xmodem block is 128, right?). Each time it returns from
DosRead(), it clears "hevComm" (an event semaphore). It then
waits on another semaphore before going back into the DosRead():
hevCommGo.
- Create a keyboard thread, blocked on getch() (KbdCharIn()). When
it gets a key, fire off hevKey.
- Your main thread sets up a Mux sem (DosCreateMuxWaitSem) to wait
on either of the two semaphores; when either triggers, it takes
appropriate action. In the case of hevComm going off, it should
save the data right away (empty the buffer), then fire hevCommGo
so that the comm thread can re-use its buffer.
Such a program would use 0% of the cpu when nothing is happening.
To be real slick, arrange the code so that each of the
three threads call their blocking function (DosRead, getch
and DosWaitMuxWaitSem) all on the same code page; so when
your program is minimized or swapped out, it will only use
4k of code space.
___ Maximus/2 2.01
-----------------------------------------------------------------------
> JdeBP <
___
X MegaMail 2.10 #0:
--- Maximus/2 3.00
* Origin: You'll never get dizzy doing a good turn. 905-858-8488 (1:250/292)* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4) SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 440/4 141/209 270/101 105/103 42 712/515 711/808 809 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™.