[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: thread safe functions
From: |
Andy Wingo |
Subject: |
Re: thread safe functions |
Date: |
Wed, 18 Aug 2010 08:56:15 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Hi Cedric,
On Thu 05 Aug 2010 04:27, Cedric Cellier <address@hidden> writes:
> Is there somewhere a list of guile functions that are (/are not) thread
> safe ?
>
> I ask since this morning I was after a strange bug because I was using
> the format module in two different thread, then learnt that these
> functions are not reentrant. I'm also interrested in the thread-safeness
> of gc-stats function.
>From "Multi-Threading" in the manual:
All libguile functions are (intended to be) robust in the face of
multiple threads using them concurrently. This means that there is no
risk of the internal data structures of libguile becoming corrupted in
such a way that the process crashes.
A program might still produce nonsensical results, though. Taking
hashtables as an example, Guile guarantees that you can use them from
multiple threads concurrently and a hashtable will always remain a valid
hashtable and Guile will not crash when you access it. It does not
guarantee, however, that inserting into it concurrently from two threads
will give useful results: only one insertion might actually happen, none
might happen, or the table might in general be modified in a totally
arbitrary manner. (It will still be a valid hashtable, but not the one
that you might have expected.) Guile might also signal an error when it
detects a harmful race condition.
Thus, you need to put in additional synchronizations when multiple
threads want to use a single hashtable, or any other mutable Scheme
object.
If you see any problem in libguile regarding threads, you should
certainly report it to address@hidden (no subscription required).
The same goes for Scheme code. If you have found something in `format'
that is not thread-safe, do let us know.
Thanks,
Andy
--
http://wingolog.org/