Article View: comp.sys.amiga.tech
Article #8308Re: Killing a task using SetExcept()
From: Matt Dillon
Date: Tue, 08 Mar 1988 09:23
Date: Tue, 08 Mar 1988 09:23
34 lines
1816 bytes
1816 bytes
>Hello, > I am trying to design a neat way to kill tasks spawned by my programs. >I want to use exception processing via SetExcept and the tc_ExceptCode field. >What I mean to do is point tc_ExceptCode at my cleanup routine and use >SetExcept to point a signal that will start thisup from within my task. >My question is how will the system react to a RemTask() call from within the >exception? The more I think about this the more it seems to me that I am >going to crash the system- what is the true wisdom on this? > >Thanks! Since the exception handler runs in user mode in the task's context on the task's stack, you should be able to RemTask(NULL) fine.... of course, the only way to find out is to try! There is a major problem though, that you don't want to kill a task while it is in the middle of a library call. Usually, one needs a more synchronous way of killing a dedicated child task... in the above method, you are not guarenteed that the task will be killed immediately after you send the Signal(). I usually do it it like this: Totally synchronous method: Use one of the preallocated signals to mean "please die", and signal the task in question with that signal. The task would then Forbid(), signal you back, and RemTask(NULL) (while still forbid()en). When you get the signal back, the task is guarenteed to not exist anymore and you can clean up its resources (memory, seglist...) -Matt
Technical Details
Message-ID:
<8803080923.AA17348@cory.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: Killing a task using SetExcept() Message-ID: <8803080923.AA17348@cory.Berkeley.EDU> Date: 8 Mar 88 09:23:10 GMT Sender: usenet@ucbvax.BERKELEY.EDU Lines: 34