[elephant-devel] Serialization

Ian Eslick eslick at csail.mit.edu
Tue Nov 21 06:30:42 UTC 2006


On Nov 21, 2006, at 12:40 AM, Pierre THIERRY wrote:

> Scribit Ian Eslick dies 20/11/2006 hora 09:56:
>> 1) Special start-elephant-thread macro
>
> I'm not sure it is viable to put this kind of burden on the user.
>
>> 2) Bind a C-library which provides a CPU independent compare-and-swap
>> instruction and/or a lock-free queue so we can share a pool of
>> circularity buffers among processes in a lock-free way
>
> Why couldn't it be achieved in Lisp?

The Common Lisp spec doesn't expose this hardware-specific feature  
that most CPUs have.  It turns out that most implementations have a  
non-standard call 'without-interrupts' that allow you, on a single  
CPU architecture, to suspend interrupts and create a low-cost  
critical section.  That seemed the best tradeoff so that's what I've  
used in the serializer and memutil buffer pools.

However this isn't nearly as robust, high performing or elegant as  
the compare-and-swap, hardware-guaranteed atomicity used in a lock- 
free algorithm.

(Allegro has an undocumented function that I think does this, but  
it's not easily portable among implementations and it's tricky to get  
the compiler to generate it correctly and they recommended i not use  
it - too many opportunities to shoot oneself in the foot, I imagine)

Once you are outside the specification, there isn't anything that's  
'in lisp' so to speak.  If I had a CPU-generic assembler with all the  
interesting hardware features and/or a compiler-macro-like facility  
that allowed me to specify anything supported by the hardware then I  
could do everything in lisp (only system to do this was Genera and  
Lisp Machines).  However, without getting inside the compiler the  
only way I can get access to instructions/capabilities of the  
hardware not exposed by my implementation is to call out to a C or  
assembly routine that can/does.  Fortunately I didn't have to do it  
in this case.

Cheers,
Ian






More information about the elephant-devel mailing list