[Top][All Lists]

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

Re: Using define in multiple threads?

From: Ludovic Courtès
Subject: Re: Using define in multiple threads?
Date: Mon, 17 Nov 2008 15:57:06 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)


Han-Wen Nienhuys <address@hidden> writes:

> Linas Vepstas escreveu:
>> Is it "safe" or "legal" to use define in multiple threads?
> I guess not.  Someone -I forgot who- put in the pthreads without thinking 
> through the consequences.
> Look through eval.c, you´ll see
>   SCM_SETCAR (expr, SCM_IM_DO);
>   // *
>   SCM_SETCDR (expr, tail);
> which is very dubious if a thread switch happens at (*)

You're answering a more general question: "is it safe to evaluate code
in multiple threads?".  I'm afraid your answer is correct, but, if it
happens that the code to be evaluated has already been memoized, then
everything's alright.  Thankfully, the VM will soon save us from this.

Besides, as Linas noted, the hash table implementation isn't
thread-safe, which makes it "unsafe" to `define' in parallel.


reply via email to

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