[Openmcl-devel] Is setf atomic?

Andrew Shalit alms at clozure.com
Tue Nov 6 12:59:27 PST 2007


What would it mean for (setf var 42) to be thread-safe or not thread  
safe?

I can understand what this might mean for

(setf var (do-something-complex))  ;; lots of stuff can happen during  
the calculation of do-something-complex
                                                                ;;and  
between the time that value is calculated and the variable is assigned

and I can understand what it could mean for

(progn
   (setf var 42)
   var)  ;;var might not be 42 at this point

or

(progn
   (setf var 42)
   (setf foo var))  ;; foo could be set to pretty much anything

But what would it mean for (setf var 42) in isolation not to be thread  
safe?

On Nov 6, 2007, at 3:47 PM, Pascal Costanza wrote:

> So to get this straight - are you saying that even a setf on a simple
> variable, for example like (setf var 42) when var is not a symbol
> macro, is potentially not thread-safe?
>
> Pascal
>
> On 6 Nov 2007, at 18:42, Gary Byers wrote:
>
>> If you're asking whether global variables and property lists are
>> potentially shared resources just like everything else or whether
>> they have some sort of magic dispensation ... well, there isn't
>> any magic dispensation.
>>
>> There are certainly lots of low-level internal things in OpenMCL that
>> do atomic read-modify-write operations that're guaranteed (by the
>> hardware) to either succeed or detectably fail.  It's generally hard
>> to map things like SETF (whose specified behavior is about as far  
>> from
>> "atomic update" as one could imagine) onto these primitives, and it's
>> not clear that that'd be desirable: such an atomic operation is  
>> likely
>> to be an order of magnitude slower than a non-atomic operation in
>> terms
>> of direct costs, and may have all kinds of indirect costs
>> (serialization
>> on an machine that does out-of-order memory operations and/or
>> execution.)
>>
>>
>> On Tue, 6 Nov 2007, Pascal Costanza wrote:
>>
>>> Hi,
>>>
>>> Are a setf on a simple variable, and a setf on a property list  
>>> (i.e.,
>>> a (setf getf)), thread-safe (atomic) operations in OpenMCL?
>>>
>>>
>>> Thanks,
>>> Pascal
>>>
>>> -- 
>>> Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
>>> Vrije Universiteit Brussel, Programming Technology Lab
>>> Pleinlaan 2, B-1050 Brussel, Belgium
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Openmcl-devel mailing list
>>> Openmcl-devel at clozure.com
>>> http://clozure.com/mailman/listinfo/openmcl-devel
>>>
>>>
>
> -- 
> Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
> Vrije Universiteit Brussel, Programming Technology Lab
> Pleinlaan 2, B-1050 Brussel, Belgium
>
>
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list