1#!/usr/sbin/dtrace -s
2/*
3 * dispqlen.d - dispatcher queue length by CPU.
4 *              Written using DTrace (Solaris 10 3/05).
5 *
6 * $Id: dispqlen.d 3 2007-08-01 10:50:08Z brendan $
7 *
8 * USAGE:	dispqlen.d		# hit Ctrl-C to end sample
9 *
10 * NOTES: The dispatcher queue length is an indication of CPU saturation.
11 * It is not an indicatior of utilisation - the CPUs may or may not be
12 * utilised when the dispatcher queue reports a length of zero.
13 *
14 * SEE ALSO:    uptime(1M)
15 *
16 * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
17 *
18 * CDDL HEADER START
19 *
20 *  The contents of this file are subject to the terms of the
21 *  Common Development and Distribution License, Version 1.0 only
22 *  (the "License").  You may not use this file except in compliance
23 *  with the License.
24 *
25 *  You can obtain a copy of the license at Docs/cddl1.txt
26 *  or http://www.opensolaris.org/os/licensing.
27 *  See the License for the specific language governing permissions
28 *  and limitations under the License.
29 *
30 * CDDL HEADER END
31 *
32 * 27-Jun-2005  Brendan Gregg   Created this.
33 * 14-Feb-2006	   "      "	Last update.
34 */
35
36#pragma D option quiet
37
38dtrace:::BEGIN
39{
40	printf("Sampling... Hit Ctrl-C to end.\n");
41}
42
43profile:::profile-1000hz
44{
45	@queue[cpu] =
46	    lquantize(curthread->t_cpu->cpu_disp->disp_nrunnable, 0, 64, 1);
47}
48
49dtrace:::END
50{
51	printa(" CPU %d%@d\n", @queue);
52}
53