[Mono-list] solution for Thread::Abort()
Thu, 8 Aug 2002 21:34:44 +0200
2 stupid questions:
1. Can't you just do pthread_kill(thread, SIGSTOP) to suspend the
thread and pthread_kill(thread, SIGCONT) to resume?
2. Wine seems to be doing the threads right. Why don't you take their
code. It's GPL anyway... They seem to be using ptrace() api to modify the
thread context. I'm not sure if it works on anything but Linux (perhaps
not, but context operations aren't portable anyway).
BTW. The idea of SuspendThread(), SetThreadContext(), ResumeThread() was
once proposed by Microsoft's Dr.GUI in MSDN Library column. So perhaps
this is the right way to do it.
On 8 Aug 2002, Dietmar Maurer wrote:
> 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
> Mono-list maillist - Monofirstname.lastname@example.org