[slime-devel] Re: Use of with-lock inside without-interrupts

Nikodemus Siivola nikodemus at random-state.net
Wed Aug 6 14:58:13 UTC 2008

On Wed, Aug 6, 2008 at 5:30 PM, Helmut Eller <heller at common-lisp.net> wrote:
> * Nikodemus Siivola [2008-08-06 13:35+0200] writes:

>> and GET-LOCK has the wait wrapped in WITH-INTERRUPTS.
> You meant GET-MUTEX, right?

Yes, (and it should be RELEASE-MUTEX in the code).

>> WITH-INTERRUPTS enabled interrupts only if there is an active
>> ALLOW-WITH-INTERRUPTS lexically nested inside each WITHOUT-INTERRUPTS
>> currently on stack. (This is what I was trying to explain while
>> slightly too drunk to make a great deal of sense.)
> Would the following also work?
>  (without-interrupts (allow-with-interrupts (with-mutex (lock) ...)
> Assuming that WITH-MUTEX expands to the ordinary GET-MUTEX/RELEASE-MUTEX pair.


WITH-MUTEX is essentially the code below, except that FROB-QUEUE bit
is wrapped in WITH-LOCAL-INTERRUPTS (which is essentially

>>  (let (got-it)
>>    (without-interrupts
>>      (unwind-protect
>>          (when (setf got-it (allow-with-interrupts (get-mutex lock)))
>>             ...frob-queue...)
>>        (when got-it
>>          (release-lock lock)))))

If this was performance sensitive code you'd want to write avoid the


 -- Nikodemus

More information about the slime-devel mailing list