[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Exception when threads are deadlocked?, cryptlib wra

From: Felix Winkelmann
Subject: Re: [Chicken-users] Exception when threads are deadlocked?, cryptlib wrappers
Date: Fri, 06 Aug 2004 07:33:37 +0200
User-agent: Opera M2/7.52 (Win32, build 3834)

On Thu, 05 Aug 2004 15:03:01 +0200, Thomas Chust <address@hidden> wrote:

Felix Winkelmann wrote:
You can catch the exception in the thread that causes the deadlock
(via `handle-exceptions' or `condition-case'). For example:
 (define m (make-mutex))
(mutex-lock! m)
(handle-exceptions ex (print "ugh.") (mutex-lock! m))
 [I'm not sure whether this is SRFI-18 compliant, but I just wanted
to show handling exceptions]

Thanks for the information. But somehow I can't get this to work -- I have no problems catching other exceptions in my program, but here I probably haven't found the right place to insert the exception handler, yet ;) I will do some more analysis of the problem...

What makes this difficult is that the exception might be raised in any
thread: The scheduler keeps a list of ready threads and once this is
empty, all other threads are either dead or blocked inside a mutex
(or on i/o) and a deadlock error will be triggered.

In fact, this should be easier to handle. Since you don't know
which thread will be the active one, you would have to install
exception handlers for all threads you create (not necessarily
a bad thing, but somewhat awkward).

So, one option would be to change the scheduler to throw the deadlock
exception to a particular thread, say, the primordial one.

Would that be desirable? (comments are welcome)

I have one more question on this: What type does the exception caused by a deadlock have -- (exn runtime) or something completely different?

Yes, (exn runtime) is correct.

PS: For the same project I have created some chicken wrappers for cryptlib (a high level cryptography and communications library). If anyone was interested, I could read the chicken-setup documentation and try to package them as an egg ;)

Yes, please do!

It's really simple: say you have a file named foo.scm, then
add a setup script named foo.setup with something like this as
its content:

(run (csc -s -O2 -d0 foo.scm))
(install-extension 'foo "")

and put the files into a gzipped tarball named foo.egg. That's it!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]