1235368Sgnn#!/usr/sbin/dtrace -s
2235368Sgnn/*
3235368Sgnn * priclass.d - priority distribution by scheduling class.
4235368Sgnn *              Written using DTrace (Solaris 10 3/05)
5235368Sgnn *
6235368Sgnn * This is a simple DTrace script that samples at 1000 Hz the current
7235368Sgnn * thread's scheduling class and priority. A distribution plot is printed.
8235368Sgnn *
9235368Sgnn * With priorities, the higher the priority the better chance the thread
10235368Sgnn * has of being scheduled.
11235368Sgnn *
12235368Sgnn * This idea came from the script /usr/demo/dtrace/pri.d, which
13235368Sgnn * produces similar output for priority changes, not samples.
14235368Sgnn *
15235368Sgnn * $Id: priclass.d 3 2007-08-01 10:50:08Z brendan $
16235368Sgnn *
17235368Sgnn * USAGE:       priclass.d      # hit Ctrl-C to end sampling
18235368Sgnn *
19235368Sgnn * FIELDS:
20235368Sgnn *              value           process priority
21235368Sgnn *              count           number of samples of at least this priority
22235368Sgnn *
23235368Sgnn * Also printed is the scheduling class,
24235368Sgnn *
25235368Sgnn *		TS		time sharing
26235368Sgnn *		IA		interactive
27235368Sgnn *		RT		real time
28235368Sgnn *		SYS		system
29235368Sgnn *		FSS		fair share schedular
30235368Sgnn *
31235368Sgnn * BASED ON: /usr/demo/dtrace/pri.d
32235368Sgnn *
33235368Sgnn * SEE ALSO: DTrace Guide "profile Provider" chapter (docs.sun.com)
34235368Sgnn *           dispadmin(1M)
35235368Sgnn *
36235368Sgnn * PORTIONS: Copyright (c) 2006 Brendan Gregg.
37235368Sgnn *
38235368Sgnn * CDDL HEADER START
39235368Sgnn *
40235368Sgnn *  The contents of this file are subject to the terms of the
41235368Sgnn *  Common Development and Distribution License, Version 1.0 only
42235368Sgnn *  (the "License").  You may not use this file except in compliance
43235368Sgnn *  with the License.
44235368Sgnn *
45235368Sgnn *  You can obtain a copy of the license at Docs/cddl1.txt
46235368Sgnn *  or http://www.opensolaris.org/os/licensing.
47235368Sgnn *  See the License for the specific language governing permissions
48235368Sgnn *  and limitations under the License.
49235368Sgnn *
50235368Sgnn * CDDL HEADER END
51235368Sgnn *
52235368Sgnn * 12-Feb-2006	Brendan Gregg	Created this.
53235368Sgnn * 22-Apr-2006	   "      "	Last update.
54235368Sgnn */
55235368Sgnn
56235368Sgnn#pragma D option quiet
57235368Sgnn
58235368Sgnndtrace:::BEGIN
59235368Sgnn{
60235368Sgnn	printf("Sampling... Hit Ctrl-C to end.\n");
61235368Sgnn}
62235368Sgnn
63235368Sgnnprofile:::profile-1000hz
64235368Sgnn{
65235368Sgnn	@count[stringof(curlwpsinfo->pr_clname)]
66235368Sgnn	    = lquantize(curlwpsinfo->pr_pri, 0, 170, 10);
67235368Sgnn}
68