guile-devel
[Top][All Lists]
Advanced

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

Re: hacking on 1.7 threads


From: Marius Vollmer
Subject: Re: hacking on 1.7 threads
Date: Wed, 22 Dec 2004 17:20:29 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Julian Graham <address@hidden> writes:

>   I'm attaching a patch (against HEAD, created in guile/ via 'cvs diff
> -Nau') that represents the current state of my work on thread
> cancellation (except that I removed the cancellation-disabling stuff
> I'd added temporarily to gc.c; I wasn't super confident that it had
> any effect).

Thanks!

I haven't really looked at your code yet and I'm not yet really fully
into the threading stuff, but one thought might be worth sharing
anyway:

Guile uses pthreads to implement multi-threading, but a libguile-using
program must nevertheless obey special rules and can not just use
pthread functions while it is in 'Guile Mode'.  For example, you can
not just use pthread_mutex_lock to lock an arbitrary pthread mutex
because Guile must know when threads are blocking.  You must use
scm_mutex_lock (together with a Guile mutex) or you must leave Guile
Mode.

The same rule is likely advantageous for pthread_cancel.  We can just
state that a thread that is in Guile Mode can not be canceled with
pthread_cancel, but that you must use some other function.

Actually, wouldn't it be enough to just send a thread an asynchronous
exception, like:

    (use-modules (ice-9 threads))

    (define t
      (begin-thread
       (let loop ()
         (pk 'foo)
         (sleep 1)
         (loop))))

    (sleep 2)
    (pk 'bar)
    (system-async-mark quit t)
    (sleep 2)
    (pk 'exit)


Work needs to likely be done so that system-asyncs are able to
interrupt a blocking thread in all situations.




reply via email to

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