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

Dietmar Maurer dietmar@ximian.com
08 Aug 2002 17:25:51 +0200

One solution to implement Thread::Abort() would be to use pthreds_kill()
to raise a signal in thread to abort. The signal handler of that thread
can then impl. the Abort() functionality (realy abort - or catch the
exception (ResetAbort)).

(Un)fortunately there are no signals on windows, and it is not possible
to do things like pthreds_kill() - at least I don't know how.

Patrik pointed me to a possible solution on:

        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?

- Dietmar