TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Rob Landley
from: Peter Fitzsimmons
date: 1995-03-21 08:49:06
subject: DosKillThread useable?

RL> The only example of doskillthread I've seen is a multi-threaded com app 
 RL> that uses a blocking read from the com port to put 
 RL> bytes into a buffer the user can manipulate.  The only 
 RL> way to get it to go away when you exit is 
 RL> doskillthread. What would you suggest?

If you are exit()'ing your program,  you probably don't need to worry about
shutting that thread down (all threads die when thread 1 dies).

If you need to stop that thread for just a time (you are going to pass the
comm handle to a child program perhaps),  then you need to shut it down.

In this particular case,  I would (from another thread obviously) call the
"set dcbinfo" ioctl to change the read-mode of com.sys to
no-wait,or lower the timeout period,  so that the blocked DosRead()
returns. The read thread would then notice (via some flag/semaphore) that
it is time to shutdown (or pause),  and would do so.

If the thread is being closed down because you are going to stop using the
port forever (ie you are closing it,  to switch to a different port
perhaps),  just call DosClose() from another thread,  and the blocked
DosRead() will return with an error.

>     DosSuspendThread()

 RL> Never used this one.  I take it you should ask a 
 RL> thread to suspend itself?

Most of the time I have seen DosSuspendThread() used (by people who
obviously didn't know what they were doing),  was to manage/serialize
access to a resource;   this is what mutex semaphores are for.


--- Maximus/2 2.02p1
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)
SEEN-BY: 105/42 620/243 624/300 711/401 409 410 413 430 807 808 809 934 955
SEEN-BY: 712/407 515 628 704 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/702 3615/50 396/1 270/101 105/103 42 712/515
@PATH: 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™.