[Small-cl-src-discuss] Re: [Small-cl-src] Re: simple locking retry
Randall Randall
randall at randallsquared.com
Sun Jun 27 18:36:06 UTC 2004
On Jun 27, 2004, at 8:58 AM, Joe Marshall wrote:
> Randall Randall <randall at randallsquared.com> writes:
>
>> Second try; let's see if I get it right this time:
>>
>> This is intended to be a simple locking protocol for
>> systems that need to be usable on both serve-event-only
>> systems, like CMUCL on PPC, and more ordinary
>> multi-processing systems. I'm currently using it as
>> part of PSILISP, my webapp framework.
>>
>> This seems to work, and people I've run it by agree
>> that it seems to work, but there could be some serious
>> problem with it, so use at your own risk. I am only
>> an egg.
>>
>> This code is released as public domain.
>>
>> (defmacro enqueue (queue)
>> "Appends a unique ID to a queue."
>> (let ((id (gensym)))
>> `(let ((,id (gensym)))
>> (setf ,queue (append ,queue (list ,id)))
>> ,id)))
>
> This isn't thread safe. If two processes attempted to enter the queue
> simultaneously, one could get lost.
Because the second could run between evaluation of
,queue and evaluation of APPEND? Okay. Is there
an atomic way to do that append such that it is
thread safe without using specialized machinery not
available with serve-event?
Alternatively, I guess I could use more #+ expressions.
--
Randall Randall <randall at randallsquared.com>
Property law should use #'EQ , not #'EQUAL .
More information about the Small-cl-src-discuss
mailing list