An interface to sched_yield(). And use it in busy loops in some tests.
@include fun-sb-thread-interrupt-thread-error-thread.texinfo
@include fun-sb-thread-interrupt-thread.texinfo
@include fun-sb-thread-terminate-thread.texinfo
+@include fun-sb-thread-thread-yield.texinfo
@node Special Variables
@comment node-name, next, previous, up
"INTERRUPT-THREAD-ERROR"
"INTERRUPT-THREAD-ERROR-THREAD"
"INTERRUPT-THREAD" "TERMINATE-THREAD" "DESTROY-THREAD"
+ "THREAD-YIELD"
"MUTEX" "MAKE-MUTEX" "MUTEX-NAME" "MUTEX-VALUE"
"GET-MUTEX" "RELEASE-MUTEX" "WITH-MUTEX"
"WITH-RECURSIVE-LOCK"
(sap-ref-sap thread-sap (* sb!vm:n-word-bytes
sb!vm::thread-next-slot)))))))
+(define-alien-routine "thread_yield" int)
+
+#!+sb-doc
+(setf (fdocumentation 'thread-yield 'function)
+ "Yield the processor to other threads.")
+
#!+sb-thread
(defun symbol-value-in-thread (symbol thread-sap)
(let* ((index (sb!vm::symbol-tls-index symbol))
FSHOW_SIGNAL((stderr,"/gc_start_the_world:end\n"));
}
#endif
+
+int
+thread_yield()
+{
+#ifdef LISP_FEATURE_SB_THREAD
+ return sched_yield();
+#else
+ return 0;
+#endif
+}
(defvar *run* nil)
(defun remove-methods (list)
- (loop until *run*)
+ (loop until *run* do (sb-thread:thread-yield))
(dolist (method list)
(remove-method #'foo method)))
(defun add-methods (list)
- (loop until *run*)
+ (loop until *run* do (sb-thread:thread-yield))
(dolist (method list)
(add-method #'foo method)))
(defun test-loop ()
(note "/~S waiting for permission to run" sb-thread:*current-thread*)
- (loop until *run-cache-test*)
+ (loop until *run-cache-test* do (sb-thread:thread-yield))
(note "/~S joining the thundering herd" sb-thread:*current-thread*)
(handler-case
(loop repeat 1024 do (test-cache))
(loop repeat 10
collect (sb-thread:make-thread
(lambda ()
- (loop until run)
+ (loop until run
+ do (sb-thread:thread-yield))
(loop repeat n do (,incf x)))))))
(setf run t)
(dolist (th threads)
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.10.50"
+"1.0.10.51"