[armedbear-devel] [RFC] Support for 'synchronized' blocks in Lisp code
avodonosov at gmail.com
Tue Jul 7 21:36:11 UTC 2009
Note, btw, that "synchronized" in java is not only about locking, but
also about memory synchronization: the code in the synchronized block
is compiled so that other threads see the changes it has made to
memory and it sees changes from other threads too. Compiler doesn't
cache values in registers or other temporary places.
(let ((zu 0)
(monitor "just a string"))
(defun set-zu (val)
(setf zu val)))
(defun print-zu ()
(dotimes (i 10)
(format t "zu: ~A~%" zu)))))
If we want to preserve java "synchronized" semantics, when compiling
PRINT-ZU the compiler should not read ZU value only once, cache it in
some local variable, and the use this local to as an argument to
FORMAT in DOTIMES.
Not sure whether this requirement complicates "synchronized"
implementation for ABCL.
More information about the armedbear-devel