[Openmcl-devel] Help with lap functions
Taoufik Dachraoui
dachraoui.taoufik at gmail.com
Thu Jan 9 01:48:58 PST 2014
Hi
Please I need help with creating 2 simple lapfunctions: acquire-lock-xchg
and free-lock-xchg
assembler pseudocode for both functions follow:
(deflapfunction acquire-lock-xchg (addr)
mov 1 reg
xchg addr reg
ret reg )
(deflapfunction free-lock-xchg (addr)
mov 0 reg
xchg addr reg
ret
)
(defmacro with-critical-section (addr &body body)
"lock on addr"
`((loop when (= 1 (the fixnumm (acquire-lock-xchg ,addr))) return nil) ;
spin-wait (unwind-protect
(progn
, at body)
(free-lock-xchg ,addr))))
Usage:
(let ((x '(1 nil . 0))) (with-critical-section (cddr x) (push 2 (cadr
x))))
Do you think that such code is robust and may be used in production? (I am
developing a new algorithm for persistent hash tables for multiprocessors
systems)
Kind regards
Taoufik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20140109/2542d76b/attachment.htm>
More information about the Openmcl-devel
mailing list