[comp.os.os2.misc] OS/2 Threads......

graeme@praxis.co.uk (Graeme Cutler) (12/12/90)

----- News saved at 10 Dec 90 14:55:41 GMT

Is it possible to kill off threads from inside a C program? Is it even a
sensible question to ask? ;-)

I know that processes get started using DosExecPgm and that a process can
be terminated using DosKillProcess.  A thread can be created using
DosCreateThread or _beginthread, but there seems be no mention of a
_killthread just suspension.

I had tentatively toyed with the idea of minimising the number of
processes our application would have by using threads to perform specific
actions. 

Unfortunately I have a problem when using Netbios.  If a thread is
dedicated to sending data using Netbios and the token ring breaks the
send request just hangs there (somewhere in Netbios).  The application
will detect a failed lan by sending messages to itself with the receive
timing out, a number of time outs means the ring is dead ;-)  We then
thought that it may be sensible to kill off the thread and recreate
another there by following a standard recovery process and thus able to
say the message we were sending never got there.

I know we could uses more processes but that would just increase the
inter process communication headache we already have.

Does anyone have any advice or experience especially on Netbios that
might be useful? 

feustel@netcom.UUCP (David Feustel) (12/15/90)

It is not possible to kill threads in OS/2(not that I haven't tried to
get that capability added). Threads must commit suicide. Tough
Nugies.
-- 
David Feustel, 1930 Curdes Ave, Fort Wayne, IN 46805, (219) 482-9631
EMAIL: netcom.uucp

timo@gssc.UUCP (Timo Wilson) (12/18/90)

In article <5578@newton.praxis.co.uk> graeme@praxis.co.uk (Graeme Cutler) writes:
>----- News saved at 10 Dec 90 14:55:41 GMT
>
>Is it possible to kill off threads from inside a C program? Is it even a
>sensible question to ask? ;-)
>might be useful? 


The only method I have used to kill a thread is to send a user defined message
to your thread that tells it to die.  When your thread recieves the message,
have it terminate its own message loop.  Then do the proper cleaning up and
finally call DosExit.

There are probably other ways (semifores, etc) that could be used instead of
messages.

timo
timo@gss.com