[Mono-list] Re: solution for Thread::Abort()

Dick Porter dick@ximian.com
08 Aug 2002 17:07:53 +0100


On Thu, 2002-08-08 at 16:25, Dietmar Maurer wrote:
> 
>         1. Suspend the Thread: SuspendThread ();
>         2. get the thread context: GetThreadContext();
>         3. modify the IP in the context, we can also store argumnets we
>            want to pass in the context (in other registers). 
>         4. set the thread context: SetThreadContext();
>         5. resume the thread: ResumeThread();
> 
> After ResumeThread() that thread jumps to the modified IP, which is a
> special exception handler. That handler can simple call
> arch_handle_exception to do the work. We just need to implement those
> function in io-layer, then we can use the same code on unix.
> 
> The question is if its possible to implement a pthread based
> ResumeThread() function which uses a modified context?

I intend to implement SuspendThread() and ResumeThread() using signals.
See http://home.earthlink.net/~anneart/family/Threads/code/susp.c for
the example code from "Programming with POSIX threads" that demonstrates
the technique.  Note that a suspended thread blocks inside the signal
handler.

I'm not happy about doing platform-specific instruction pointer hacks
for Thread::Abort() unless there really is no other way.

- Dick