TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Darin McBride
date: 1996-12-10 23:14:48
subject: threads & pipes/serial ports

I haven't done much multi-threading (read: practically none) and was
wondering if anyone would be willing to help me with the design of a simple
multithreaded object.

The purpose is this: I am reading from a "file" (whether it is a
serial port or a pipe or whatever) where information may not be available
"now" but may be later.  I then wanted to put my DosRead calls in
a seperate thread (since I've heard that it can hang if it is in the main
thread, or something like that).  Eventually I'll want to use my own buffer
(probably with semaphore protection) since I'll have to do on-the-fly
transformations (for example, from \n\r or \r\n pairs to \n, as well as
others).  But how do I let the main thread know about what's going on?  Am
I right in assuming that I should use an event semaphore?  Should I then
also use event semaphores for keyboard input, and have the main thread wait
on the mux combination, and then figure out which to process?  Will this
simple design still work if I'm processing input from one or the other
while new input arrives (i.e., will the wait for mux just "fall
through" at that point)?

Any help on getting my mind around multi-threaded programming would be
appreciated (as would any good books on OS/2 multi-threading concepts...
I'm intermediate to advanced for C/C++, but definately novice when it comes
to multi-threading!).

Thanks,


--- Maximus/2 3.01
* Origin: Tanktalus' Tower BBS (PVT) (1:342/708)
SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1
@PATH: 342/5015 61 3615/50 396/1 270/101 712/515 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™.