;;; Wait Queue Benchmark (proclaim '(optimize (speed 3) (safety 0))) (load "/home/gilbert/src/sbcl-0.8.2/src/cold/chill.lisp") (load (compile-file "/home/gilbert/target-thread.lisp")) (load "package.lisp") ;;(pushnew 'CLIM-SYS-INTERNALS::USE-PIPES *features*) (pushnew 'CLIM-SYS-INTERNALS::USE-WAITQUEUE *features*) (mapcar(lambda(x)(load(compile-file x))) '("clim-sys")) (defvar *lock* (clim-sys:make-lock)) (defvar *cv* (clim-sys:make-condition-variable)) (defvar *count* 0) (defun thread-b () (clim-sys:with-lock-held (*lock*) (loop until (= *count* 0) do (clim-sys:condition-wait *cv* *lock*) (clim-sys:condition-notify *cv*) (decf *count*)))) (defun thread-a (n) (time (clim-sys:with-lock-held (*lock*) (dotimes (i n) (clim-sys:condition-notify *cv*) (clim-sys:condition-wait *cv* *lock*)) ))) (defun bounce (n) (setf *count* n) (clim-sys:make-process #'thread-b) (sleep 2) (thread-a n) (unless (= *count* 0) (warn "Failed, as ~D bounces are missing." *count*)) nil)