Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!rochester!pt.cs.cmu.edu!wb1.cs.cmu.edu!avie From: avie@wb1.cs.cmu.edu (Avadis Tevanian) Newsgroups: comp.sys.next Subject: Re: Killing a Cthread Message-ID: <10108@pt.cs.cmu.edu> Date: 4 Aug 90 06:51:07 GMT References: <9989@pt.cs.cmu.edu> <1990Jul24.230238.12159@mcs.anl.gov> Organization: NeXT, Inc. Lines: 27 In article <1990Jul24.230238.12159@mcs.anl.gov> joerg@mcs.anl.gov (Joerg) writes: >cthread_t killMe; > >thread_terminate(cthread_thread(killMe)); This will almost always not be the right thing to do. The problem here is that you end up terminating the thread out from under the C-Thread package which is not a good thing. Your best bet is to structure your application such that it can use cthread_exit. It is true that this is sometimes difficult within the confines of C-Threads. C-Threads errs on the side of simplicity, but we should probably add a cthread_terminate that can terminate other C-Threads. I will point out that using such a call would also be very dangerous as the cthread you are going to terminate could very well hold locks or other type of important state. One other thing about cthread_thread(). It does give you a mechanism to figure out which Mach thread is underlying a specific C-Thread, but you must be very careful when using Mach thread calls on this thread. You may end up changing things that will confuse the C-Threads package. -- Avadis Tevanian, Jr. (Avie) Manager, System Software NeXT, Inc. avie@NeXT.COM