;;; -*- Mode: Common-Lisp; Package: meter; Base: 10.; Patch-File: T -*-

;;; Reason: Modified start-histogram to accept a depth of 0. [9799]

;;;                           RESTRICTED RIGHTS LEGEND
;;;
;;; Use, duplication, or disclosure by the Government is subject to
;;; restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
;;; Technical Data and Computer Software clause at 52.227-7013.
;;;
;;;   TEXAS INSTRUMENTS INCORPORATED      
;;;   P.O. BOX 2909, M/S 2151             
;;;   AUSTIN, TEXAS 78769                 
;;;
;;; Copyright (C) 1989 Texas Instruments Incorporated.
;;; All rights reserved.

;;; Patch file for METER version 6.2
;;; Written 05/24/90 08:05:58 by BERGER,
;;; while running on Pasteur from band LOD2
;;; With SYSTEM 6.32, VIRTUAL-MEMORY 6.3, EH 6.7, MAKE-SYSTEM 6.3, MICRONET 6.0, LOCAL-FILE 6.2,
;;;  BASIC-PATHNAME 6.4, NETWORK-SUPPORT-COLD 6.2, BASIC-NAMESPACE 6.7, NETWORK-NAMESPACE 6.1,
;;;  DISK-IO 6.3, DISK-LABEL 6.0, BASIC-FILE 6.11, MAC-PATHNAME 6.0, NETWORK-PATHNAME 6.2,
;;;  COMPILER 6.14, TV 6.25, DATALINK 6.0, CHAOSNET 6.6, GC 6.3, MEMORY-AUX 6.0, NVRAM 6.2,
;;;  SYSLOG 6.2, STREAMER-TAPE 6.6, UCL 6.0, INPUT-EDITOR 6.0, METER 6.1, ZWEI 6.16,
;;;  DEBUG-TOOLS 6.4, NETWORK-SUPPORT 6.1, NETWORK-SERVICE 6.2, DATALINK-DISPLAYS 6.0,
;;;  FONT-EDITOR 6.1, SERIAL 6.0, PRINTER 6.6, MAC-PRINTER-TYPES 6.2, PRINTER-TYPES 6.2,
;;;  IMAGEN 6.1, SUGGESTIONS 6.1, MAIL-DAEMON 6.6, MAIL-READER 6.8, TELNET 6.1, VT100 6.0,
;;;  NAMESPACE-EDITOR 6.4, PROFILE 6.3, VISIDOC 6.7, TI-CLOS 6.46, CLEH 6.5, IP 3.62,
;;;  Experimental CLX 6.11, CLUE 6.104, X11M 6.24, Experimental BUG 11.19,  microcode 648,
;;;  Band Name: rel6.0 1/23

#!C
; From file FUNCTION_HISTOGRAM.LISP#> METER; SYS:
#10R METER#:
(COMPILER-LET ((*PACKAGE* (FIND-PACKAGE "METER"))
                          (SI:*LISP-MODE* :COMMON-LISP)
                          (*READTABLE* SYS:COMMON-LISP-READTABLE)
                          (SI:*READER-SYMBOL-SUBSTITUTIONS* SYS::*COMMON-LISP-SYMBOL-SUBSTITUTIONS*))
  (COMPILER#:PATCH-SOURCE-FILE "SYS: METER; FUNCTION_HISTOGRAM.#"


(DEFUN start-histogram (&key (interval *function-histogram-interval*)
			     (depth *function-histogram-depth*) pathname name reuse-existing-histogram)
  "Start collecting function histogram information. - See stop-histogram
Every INTERVAL 60ths of a second, a count is incremented for
the names of the top DEPTH functions in the current process.  See REPORT-HISTOGRAM.
PATHNAME is an optional pathname used to pre-load a histogram saved with SAVE-HISTOGRAM.
NAME is the name of a previous histogram to use.  If NAME or PATHNAME aren't specified,
a new histogram is created. REUSE-EXISTING-HISTOGRAM will restart an existing histogram"
  (CHECK-ARG interval (OR (NULL interval)
			  (AND (FIXNUMP interval) (PLUSP interval))) "a positive fixnum")
  (CHECK-ARG depth (AND (FIXNUMP depth)
			(or (zerop depth) (PLUSP depth)) ; DAB 12-01-89 Zero value is OK [9799]
			) "a positive fixnum")
  (CHECK-ARG name (OR (NULL name) (GET name 'function-histogram)) "the name of a function histogram")
  (WHEN (AND *function-histogram-hash-table*      ;stop, save, and kill current hash-table if it exists
	     (OR name pathname                    ; and they don't want to it.  -dkm 7/87
		 (NULL reuse-existing-histogram)))
    (stop-histogram))
  (SETQ *function-histogram-depth* 0)            ;Don't operate on hash table here & in scheduler
  (UNLESS (AND *function-histogram-hash-table*   ;initiaize new hash table if one doesn't exist or
	       reuse-existing-histogram)         ;  not reusing the existing one -dkm 7/87
    (WITH-LOCK (*function-histogram-lock*)
      (SETQ *function-histogram-hash-table*
	    (OR (GET name 'function-histogram)
		(ALLOCATE-RESOURCE 'function-histogram-hash-table 5000.)))))
      
  (WHEN pathname
      (restore-histogram pathname))
  (SETF (GETHASH 'histogram-threshold *function-histogram-hash-table*) '(0))
  (modify-histogram :interval interval :depth depth)
  (enable-function-histogram-processes) ;added here to enable specified process for this histogram -dkm 7/85
  (enable-function-histogram-update)  ;new function to enable the update process -dkm 7/87
  t)
))
