[plt-scheme] dynamic-wind & kill-thread

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Apr 21 06:42:30 EDT 2009

On Tue, Apr 21, 2009 at 3:58 AM, YC <yinso.chen at gmail.com> wrote:
> Hi -
> what happens when a thread is killed in the middle of executing a
> dynamic-wind block?  Does the post-thunk get executed still?

No, it doesn't.

> I am tracing my hanging thread problem based on Matthew's recommendatioin,
> and the trace lead me to a dynamic-wind block that first wait on a semaphore
> and release it in post-thunk.  If the thread can be killed without executing
> post-thunk then the next thread would wait indefinitely (which appears to be
> what I am experiencing).
> If I am on the right track - how can one write kill-safe semaphore code?

In general, one might have to rewrite the program to make it
kill-safe. That is, there is no way to just take code that
synchronizes in some arbitrary way and make it kill-safe. Perhaps if
you can say more about what the actual syncronization protocol is, we
can help you make it kill-safe.


Posted on the users mailing list.