1N/A#!/usr/sbin/dtrace -s
1N/A/*
1N/A * threaded.d - sample multi-threaded CPU usage.
1N/A * Written using DTrace (Solaris 10 3/05).
1N/A *
1N/A * This measures thread IDs as a process runs across multiple CPUs.
1N/A * It is a simple script that can help determine if a multi-threaded
1N/A * application is effectively using it's threads, or if the threads have
1N/A * serialised. See the example file in Docs/Examples/threaded_example.txt
1N/A * for a demonstration.
1N/A *
1N/A * $Id: threaded.d 3 2007-08-01 10:50:08Z brendan $
1N/A *
1N/A * USAGE: threaded.d
1N/A *
1N/A * FIELDS:
1N/A * PID process ID
1N/A * CMD process name
1N/A * value thread ID
1N/A * count number of samples
1N/A *
1N/A * SEE ALSO: prstat -L
1N/A *
1N/A * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
1N/A *
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License, Version 1.0 only
1N/A * (the "License"). You may not use this file except in compliance
1N/A * with the License.
1N/A *
1N/A * You can obtain a copy of the license at Docs/cddl1.txt
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * CDDL HEADER END
1N/A *
1N/A * Author: Brendan Gregg [Sydney, Australia]
1N/A *
1N/A * 25-Jul-2005 Brendan Gregg Created this.
1N/A * 25-Jul-2005 " " Last update.
1N/A */
1N/A
1N/A#pragma D option quiet
1N/A
1N/A/*
1N/A * Sample at 100 Hertz
1N/A */
1N/Aprofile:::profile-100
1N/A/pid != 0/
1N/A{
1N/A @sample[pid, execname] = lquantize(tid, 0, 128, 1);
1N/A}
1N/A
1N/A/*
1N/A * Print output every 1 second
1N/A */
1N/Aprofile:::tick-1sec
1N/A{
1N/A printf("%Y,\n", walltimestamp);
1N/A printa("\n PID: %-8d CMD: %s\n%@d", @sample);
1N/A printf("\n");
1N/A trunc(@sample);
1N/A}