digitalmars.D - How to force a thread to unwind it's stack?
- Sascha Katzner (16/16) Aug 27 2008 Why is there no way in D to force a thread to unwind it's stack, for
- davidl (8/24) Aug 27 2008 Honestly, i didn't get the exception idea at the very first glance. Yeah...
- Frank Benoit (3/23) Aug 27 2008 a tango ticket related to this:
- davidl (19/42) Aug 27 2008 It's pity that modern OS not get this useful API built-in. That's design...
Why is there no way in D to force a thread to unwind it's stack, for example by sending it an exception like you do in Java with "Thread.interrupt()"? Suppose you have an application which has a thread that has some important resources which need to be released before the application can quit and this thread is currently busy with something which is out of your sphere of influence (like waiting for a network packet or something), so that in the foreseeable future it can't look for a flag of the main thread to quit and release it's resources. How do you force this thread to terminate without compromising the resources it holds or having to release the resources manually in the main thread? Here is an example of how D could implement this stack unwinding: "http://www.woodmann.com/crackz/Tutorials/Seh.htm#Exception handling in multi-threaded applications" (8th point) LLAP, Sascha
Aug 27 2008
在 Wed, 27 Aug 2008 23:04:34 +0800,Sascha Katzner <sorry.no spam.invalid> 写道:Why is there no way in D to force a thread to unwind it's stack, for example by sending it an exception like you do in Java with "Thread.interrupt()"? Suppose you have an application which has a thread that has some important resources which need to be released before the application can quit and this thread is currently busy with something which is out of your sphere of influence (like waiting for a network packet or something), so that in the foreseeable future it can't look for a flag of the main thread to quit and release it's resources. How do you force this thread to terminate without compromising the resources it holds or having to release the resources manually in the main thread? Here is an example of how D could implement this stack unwinding: "http://www.woodmann.com/crackz/Tutorials/Seh.htm#Exception handling in multi-threaded applications" (8th point) LLAP, SaschaHonestly, i didn't get the exception idea at the very first glance. Yeah, it's a great idea!! And it SHOULD be in STDLIB -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Aug 27 2008
Sascha Katzner schrieb:Why is there no way in D to force a thread to unwind it's stack, for example by sending it an exception like you do in Java with "Thread.interrupt()"? Suppose you have an application which has a thread that has some important resources which need to be released before the application can quit and this thread is currently busy with something which is out of your sphere of influence (like waiting for a network packet or something), so that in the foreseeable future it can't look for a flag of the main thread to quit and release it's resources. How do you force this thread to terminate without compromising the resources it holds or having to release the resources manually in the main thread? Here is an example of how D could implement this stack unwinding: "http://www.woodmann.com/crackz/Tutorials/Seh.htm#Exception handling in multi-threaded applications" (8th point) LLAP, Saschaa tango ticket related to this: http://dsource.org/projects/tango/ticket/1009
Aug 27 2008
在 Thu, 28 Aug 2008 08:09:06 +0800,Frank Benoit <keinfarbton googlemail.com> 写道:Sascha Katzner schrieb:It's pity that modern OS not get this useful API built-in. That's design flaw clearly. I'm pretty sure future GOOD OS will get this API integrated if the designers are not idiots. As soon as OS designers realize how useful it is, they will get it done. But I doubt it's really a tough thing to implement with support from OS. especially on windows. the possible user-mode implementation i can think of firstly stop the thread, then write throw exception code to EIP, then resume the thread. yet it's not a clean solution. or even with such thing, the application might still hang becuase the thread might stop at a WaitForSingleObject or WaitForMultipleObject. So that's why I say it should be built-in the OS. -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/Why is there no way in D to force a thread to unwind it's stack, for example by sending it an exception like you do in Java with "Thread.interrupt()"? Suppose you have an application which has a thread that has some important resources which need to be released before the application can quit and this thread is currently busy with something which is out of your sphere of influence (like waiting for a network packet or something), so that in the foreseeable future it can't look for a flag of the main thread to quit and release it's resources. How do you force this thread to terminate without compromising the resources it holds or having to release the resources manually in the main thread? Here is an example of how D could implement this stack unwinding: "http://www.woodmann.com/crackz/Tutorials/Seh.htm#Exception handling in multi-threaded applications" (8th point) LLAP, Saschaa tango ticket related to this: http://dsource.org/projects/tango/ticket/1009
Aug 27 2008