Changeset 14748


Ignore:
Timestamp:
Apr 29, 2011, 12:51:11 AM (8 years ago)
Author:
gb
Message:

CLEANUP-THREAD-TCR: a thread needs to hold the state-change lock to
set its lisp-thread.tcr to NIL.

LISP-THREAD-SUSPEND-COUNT: hold the state-change lock while accessing
another thread's TCR.

(More things should probably do this.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-lisp-threads.lisp

    r14641 r14748  
    441441    (if (logbitp arch::tcr-flag-bit-awaiting-preset flags)
    442442      (thread-change-state thread :run :reset)
    443       (progn
     443      (with-lock-grabbed ((lisp-thread.state-change-lock thread))
    444444        (thread-change-state thread :run :exit)
    445445        (setf (lisp-thread.tcr thread) nil)))))
     
    492492
    493493(defun lisp-thread-suspend-count (thread)
    494   (with-macptrs (tcrp)
    495     (%setf-macptr-to-object tcrp (lisp-thread.tcr thread))
    496     (unless (%null-ptr-p tcrp)
    497       #+(and windows-target x8632-target)
    498       (let ((aux (%get-ptr tcrp (- target::tcr.aux target::tcr-bias))))
    499         (%get-unsigned-long aux target::tcr-aux.suspend-count))
    500       #-(and windows-target x8632-target)
    501       (#+32-bit-target %get-unsigned-long
    502        #+64-bit-target %%get-unsigned-longlong tcrp target::tcr.suspend-count))))
     494  (with-lock-grabbed ((lisp-thread.state-change-lock thread))
     495    (let* ((tcr (lisp-thread.tcr thread)))
     496      (if (null tcr)
     497        0
     498        (with-macptrs (tcrp)
     499          (%setf-macptr-to-object tcrp tcr)
     500          #+(and windows-target x8632-target)
     501          (let ((aux (%get-ptr tcrp (- target::tcr.aux target::tcr-bias))))
     502            (%get-unsigned-long aux target::tcr-aux.suspend-count))
     503          #-(and windows-target x8632-target)
     504          (#+32-bit-target %get-unsigned-long
     505                             #+64-bit-target %%get-unsigned-longlong tcrp target::tcr.suspend-count))))))
    503506
    504507(defun tcr-clear-preset-state (tcr)
Note: See TracChangeset for help on using the changeset viewer.