Changeset 7925


Ignore:
Timestamp:
Dec 21, 2007, 10:43:15 AM (12 years ago)
Author:
gb
Message:

Add :monitor-futex-wait to *known-optional-features*.

RECURSIVE-LOCK-WHOSTATE: get the whostate field, not the value field ...

Deal with whostate a little differently in FUTEX-WAIT, LOCK-FUTEX, and
callers.

Conditionally (#+monitor-futex-wait) count futex-wait syscalls and the
time spent in them in CCL::*TOTAL-FUTEX-WAIT-CALLS* and
CCL::*TOTAL-FUTEX-WAIT-TIMES*, respectively. (This isn't thread-safe:
two threads trying to increment these values at the same time can cause
the results to be inconsistent.)

Location:
branches/working-0711/ccl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-0/l0-aprims.lisp

    r7721 r7925  
    150150  (if (and (eq target::subtag-lock (typecode r))
    151151           (eq (%svref r target::lock.kind-cell) 'recursive-lock))
    152     (or (%svref r target::lock._value-cell)
    153         (setf (%svref r target::lock._value-cell)
     152    (or (%svref r target::lock.whostate-cell)
     153        (setf (%svref r target::lock.whostate-cell)
    154154              (format nil "Lock ~s wait" r)))
    155155    (report-bad-arg r 'recursive-lock)))
  • branches/working-0711/ccl/level-0/l0-misc.lisp

    r7866 r7925  
    586586
    587587#+futex
    588 (defun futex-wait (p val whostate)
    589   (with-process-whostate (whostate)
    590     (syscall syscalls::futex p FUTEX-WAIT val (%null-ptr) (%null-ptr) 0)))
     588(progn
     589  #-monitor-futex-wait
     590  (defun futex-wait (p val whostate)
     591    (with-process-whostate (whostate)
     592      (syscall syscalls::futex p FUTEX-WAIT val (%null-ptr) (%null-ptr) 0)))
     593  #+monitor-futex-wait
     594  (progn
     595    (defparameter *total-futex-wait-calls* 0)
     596    (defparameter *total-futex-wait-times* 0)
     597    (defun futex-wait (p val whostate)
     598      (with-process-whostate (whostate)
     599        (let* ((start (get-internal-real-time)))
     600          (incf *total-futex-wait-calls*)
     601          (syscall syscalls::futex p FUTEX-WAIT val (%null-ptr) (%null-ptr) 0)
     602          (incf *total-futex-wait-times* (- (get-internal-real-time) start)))))))
     603   
     604
     605
    591606
    592607#+futex
     
    595610
    596611#+futex
    597 (defun %lock-futex (p wait-level whostate)
     612(defun %lock-futex (p wait-level lock fwhostate)
    598613  (let* ((val (%ptr-store-conditional p futex-avail futex-locked)))
    599614    (declare (fixnum val))
     
    602617          (if (eql val futex-contended)
    603618            (let* ((*interrupt-level* wait-level))
    604               (futex-wait p val whostate))
     619              (futex-wait p val (if fwhostate (funcall fwhostate lock) "futex wait")))
    605620            (setq val futex-contended))
    606621          (when (eql futex-avail (xchgl val p))
     
    629644     (cond ((eql self (%get-object ptr target::lockptr.owner))
    630645            (incf (%get-natural ptr target::lockptr.count)))
    631            (t (%lock-futex ptr level (recursive-lock-whostate lock))
     646           (t (%lock-futex ptr level lock #'recursive-lock-whostate)
    632647              (%set-object ptr target::lockptr.owner self)
    633648              (setf (%get-natural ptr target::lockptr.count) 1)))
     
    879894      (note-lock-wait lock)
    880895      (without-interrupts
    881        (%lock-futex ptr level "futex wait")               ;(%get-spin-lock (%inc-ptr ptr target::rwlock.spin))
     896       (%lock-futex ptr level lock nil)
    882897       (if (eq (%get-object ptr target::rwlock.writer) tcr)
    883898         (progn
     
    904919               (let* ((*interrupt-level* level))
    905920                 (futex-wait write-signal waitval (rwlock-write-whostate lock)))))
    906            (%lock-futex ptr level "futex wait")
     921           (%lock-futex ptr level lock nil)
    907922           (decf (%get-natural ptr target::rwlock.blocked-writers))))))))
    908923
     
    959974      (note-lock-wait lock)
    960975      (without-interrupts
    961        (%lock-futex ptr level "futex wait")
     976       (%lock-futex ptr level lock nil)
    962977       (if (eq (%get-object ptr target::rwlock.writer) tcr)
    963978         (progn
     
    983998             (let* ((*interrupt-level* level))
    984999               (futex-wait reader-signal waitval (rwlock-read-whostate lock))))
    985            (%lock-futex ptr level "futex wait")
     1000           (%lock-futex ptr level lock nil)
    9861001           (decf (%get-natural ptr target::rwlock.blocked-readers))))))))
    9871002
     
    10551070           (wakeup 0))
    10561071    (without-interrupts
    1057      (%lock-futex ptr -1 "futex wait")
     1072     (%lock-futex ptr -1 lock nil)
    10581073     (let* ((state (%get-signed-natural ptr target::rwlock.state))
    10591074            (tcr (%current-tcr)))
     
    11061121      (without-interrupts
    11071122       #+futex
    1108        (%lock-futex ptr level "futex wait")
     1123       (%lock-futex ptr level lock nil)
    11091124       #-futex
    11101125       (%get-spin-lock ptr)
  • branches/working-0711/ccl/lib/compile-ccl.lisp

    r7908 r7925  
    456456    (:darwinx8664 "darwinx8664")))
    457457
    458 (defparameter *known-optional-features* '(:lock-accouting :count-gf-calls))
     458(defparameter *known-optional-features* '(:lock-accouting :count-gf-calls :monitor-futex-wait))
    459459(defvar *build-time-optional-features* nil)
    460460
Note: See TracChangeset for help on using the changeset viewer.