summaryrefslogtreecommitdiffstats
path: root/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched')
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup0
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d52
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d42
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d45
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d31
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d38
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d64
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d37
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d60
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d46
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d57
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d95
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d40
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d44
-rw-r--r--src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d40
19 files changed, 841 insertions, 0 deletions
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/Makefile.kup
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d
new file mode 100644
index 00000000..ab65e956
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/firebird.d
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::sleep
+/execname == "MozillaFirebird" && curlwpsinfo->pr_stype == SOBJ_CV/
+{
+ bedtime[curlwpsinfo->pr_addr] = timestamp;
+}
+
+sched:::wakeup
+/execname == "MozillaFirebird" && bedtime[args[0]->pr_addr]/
+{
+ @[args[1]->pr_pid, args[0]->pr_lwpid, pid, curlwpsinfo->pr_lwpid] =
+ quantize(timestamp - bedtime[args[0]->pr_addr]);
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+sched:::wakeup
+/bedtime[args[0]->pr_addr]/
+{
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+END
+{
+ printa("%d/%d sleeping on %d/%d:\n%@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d
new file mode 100644
index 00000000..0fcfa1c1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/howlong.d
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::off-cpu
+/curlwpsinfo->pr_state == SSLEEP/
+{
+ self->cpu = cpu;
+ self->ts = timestamp;
+}
+
+sched:::on-cpu
+/self->ts/
+{
+ @[self->cpu == cpu ?
+ "sleep time, no CPU migration" : "sleep time, CPU migration"] =
+ lquantize((timestamp - self->ts) / 1000000, 0, 500, 25);
+ self->ts = 0;
+ self->cpu = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d
new file mode 100644
index 00000000..8e30ac44
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/nscd.d
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::sleep
+/curlwpsinfo->pr_stype == SOBJ_SHUTTLE/
+{
+ bedtime[curlwpsinfo->pr_addr] = timestamp;
+}
+
+sched:::wakeup
+/execname == "nscd" && bedtime[args[0]->pr_addr]/
+{
+ @[stringof(curpsinfo->pr_fname), stringof(args[1]->pr_fname)] =
+ quantize(timestamp - bedtime[args[0]->pr_addr]);
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+sched:::wakeup
+/bedtime[args[0]->pr_addr]/
+{
+ bedtime[args[0]->pr_addr] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d
new file mode 100644
index 00000000..ea76fd79
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pri.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::change-pri
+{
+ @[stringof(args[0]->pr_clname)] =
+ lquantize(args[2] - args[0]->pr_pri, -50, 50, 5);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d
new file mode 100644
index 00000000..2c80e6a7
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/pritime.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ start = timestamp;
+}
+
+sched:::change-pri
+/args[1]->pr_pid == $1 && args[0]->pr_lwpid == $2/
+{
+ printf("%d %d\n", timestamp - start, args[2]);
+}
+
+tick-1sec
+/++n == 5/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d
new file mode 100644
index 00000000..a34ae4cf
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qlen.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::enqueue
+{
+ this->len = qlen[args[2]->cpu_id]++;
+ @[args[2]->cpu_id] = lquantize(this->len, 0, 100);
+}
+
+sched:::dequeue
+/qlen[args[2]->cpu_id]/
+{
+ qlen[args[2]->cpu_id]--;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d
new file mode 100644
index 00000000..54ebf5f5
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/qtime.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::enqueue
+{
+ ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id] =
+ timestamp;
+}
+
+sched:::dequeue
+/ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id]/
+{
+ @[args[2]->cpu_id] = quantize(timestamp -
+ ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id]);
+ ts[args[0]->pr_lwpid, args[1]->pr_pid, args[2]->cpu_id] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d
new file mode 100644
index 00000000..88427593
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/tick.d
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::tick,
+sched:::enqueue
+{
+ @[probename] = lquantize((timestamp / 1000000) % 10, 0, 10);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d
new file mode 100644
index 00000000..e24a80ad
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/ticktime.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+uint64_t last[int];
+
+sched:::tick
+/last[cpu]/
+{
+ @[cpu] = min(timestamp - last[cpu]);
+}
+
+sched:::tick
+{
+ last[cpu] = timestamp;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d
new file mode 100644
index 00000000..d8b6edb0
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whatfor.d
@@ -0,0 +1,64 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::off-cpu
+/curlwpsinfo->pr_state == SSLEEP/
+{
+ /*
+ * We're sleeping. Track our sobj type.
+ */
+ self->sobj = curlwpsinfo->pr_stype;
+ self->bedtime = timestamp;
+}
+
+sched:::off-cpu
+/curlwpsinfo->pr_state == SRUN/
+{
+ self->bedtime = timestamp;
+}
+
+sched:::on-cpu
+/self->bedtime && !self->sobj/
+{
+ @["preempted"] = quantize(timestamp - self->bedtime);
+ self->bedtime = 0;
+}
+
+sched:::on-cpu
+/self->sobj/
+{
+ @[self->sobj == SOBJ_MUTEX ? "kernel-level lock" :
+ self->sobj == SOBJ_RWLOCK ? "rwlock" :
+ self->sobj == SOBJ_CV ? "condition variable" :
+ self->sobj == SOBJ_SEMA ? "semaphore" :
+ self->sobj == SOBJ_USER ? "user-level lock" :
+ self->sobj == SOBJ_USER_PI ? "user-level prio-inheriting lock" :
+ self->sobj == SOBJ_SHUTTLE ? "shuttle" : "unknown"] =
+ quantize(timestamp - self->bedtime);
+
+ self->sobj = 0;
+ self->bedtime = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d
new file mode 100644
index 00000000..af026244
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/where.d
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+sched:::on-cpu
+{
+ self->ts = timestamp;
+}
+
+sched:::off-cpu
+/self->ts/
+{
+ @[cpu] = quantize(timestamp - self->ts);
+ self->ts = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d
new file mode 100644
index 00000000..ddd13f75
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whererun.d
@@ -0,0 +1,60 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ start = timestamp;
+}
+
+sched:::on-cpu
+/execname == $$1/
+{
+ self->ts = timestamp;
+}
+
+sched:::off-cpu
+/self->ts/
+{
+ @[cpu] = sum(timestamp - self->ts);
+ self->ts = 0;
+}
+
+profile:::tick-1sec
+/++x == 10/
+{
+ exit(0);
+}
+
+dtrace:::END
+{
+ printf("CPU distribution over %d seconds:\n\n",
+ (timestamp - start) / 1000000000);
+ printf("CPU microseconds\n--- ------------\n");
+ normalize(@, 1000);
+ printa("%3d %@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d
new file mode 100644
index 00000000..f0243d60
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whofor.d
@@ -0,0 +1,46 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::sleep
+/!(curlwpsinfo->pr_flag & PR_ISSYS) && curlwpsinfo->pr_stype == SOBJ_CV/
+{
+ bedtime[curlwpsinfo->pr_addr] = timestamp;
+}
+
+sched:::wakeup
+/bedtime[args[0]->pr_addr]/
+{
+ @[stringof(args[1]->pr_fname), execname] =
+ quantize(timestamp - bedtime[args[0]->pr_addr]);
+ bedtime[args[0]->pr_addr] = 0;
+}
+
+END
+{
+ printa("%s sleeping on %s:\n%@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d
new file mode 100644
index 00000000..e8dd8633
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whopreempt.d
@@ -0,0 +1,57 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::preempt
+{
+ self->preempt = 1;
+}
+
+sched:::remain-cpu
+/self->preempt/
+{
+ self->preempt = 0;
+}
+
+sched:::off-cpu
+/self->preempt/
+{
+ /*
+ * If we were told to preempt ourselves, see who we ended up giving
+ * the CPU to.
+ */
+ @[stringof(args[1]->pr_fname), args[0]->pr_pri, execname,
+ curlwpsinfo->pr_pri] = count();
+ self->preempt = 0;
+}
+
+END
+{
+ printf("%30s %3s %30s %3s %5s\n", "PREEMPTOR", "PRI",
+ "PREEMPTED", "PRI", "#");
+ printa("%30s %3d %30s %3d %5@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d
new file mode 100644
index 00000000..c2ab47a3
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whoqueue.d
@@ -0,0 +1,95 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+#pragma D option nspec=4
+#pragma D option specsize=100k
+
+int maxlen;
+int spec[int];
+
+sched:::enqueue
+{
+ this->len = ++qlen[this->cpu = args[2]->cpu_id];
+ in[args[0]->pr_addr] = timestamp;
+}
+
+sched:::enqueue
+/this->len > maxlen && spec[this->cpu]/
+{
+ /*
+ * There is already a speculation for this CPU. We just set a new
+ * record, so we'll discard the old one.
+ */
+ discard(spec[this->cpu]);
+}
+
+sched:::enqueue
+/this->len > maxlen/
+{
+ /*
+ * We have a winner. Set the new maximum length and set the timestamp
+ * of the longest length.
+ */
+ maxlen = this->len;
+ longtime[this->cpu] = timestamp;
+
+ /*
+ * Now start a new speculation, and speculatively trace the length.
+ */
+ this->spec = spec[this->cpu] = speculation();
+ speculate(this->spec);
+ printf("Run queue of length %d:\n", this->len);
+}
+
+sched:::dequeue
+/(this->in = in[args[0]->pr_addr]) &&
+ this->in <= longtime[this->cpu = args[2]->cpu_id]/
+{
+ speculate(spec[this->cpu]);
+ printf(" %d/%d (%s)\n",
+ args[1]->pr_pid, args[0]->pr_lwpid,
+ stringof(args[1]->pr_fname));
+}
+
+sched:::dequeue
+/qlen[args[2]->cpu_id]/
+{
+ in[args[0]->pr_addr] = 0;
+ this->len = --qlen[args[2]->cpu_id];
+}
+
+sched:::dequeue
+/this->len == 0 && spec[this->cpu]/
+{
+ /*
+ * We just processed the last thread that was enqueued at the time
+ * of longest length; commit the speculation, which by now contains
+ * each thread that was enqueued when the queue was longest.
+ */
+ commit(spec[this->cpu]);
+ spec[this->cpu] = 0;
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d
new file mode 100644
index 00000000..c698e4f1
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/whosteal.d
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+sched:::dequeue
+/args[2]->cpu_id != -1 && cpu != args[2]->cpu_id &&
+ (curlwpsinfo->pr_flag & PR_IDLE)/
+{
+ @[stringof(args[1]->pr_fname), args[2]->cpu_id] =
+ lquantize(cpu, 0, 100);
+}
+
+END
+{
+ printa("%s stolen from CPU %d by:\n%@d\n", @);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d
new file mode 100644
index 00000000..bb5ed33c
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xterm.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ start = timestamp;
+}
+
+sched:::wakeup
+/stringof(args[1]->pr_fname) == "xterm"/
+{
+ @[execname] = lquantize((timestamp - start) / 1000000000, 0, 10);
+}
+
+profile:::tick-1sec
+/++x == 10/
+{
+ exit(0);
+}
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d
new file mode 100644
index 00000000..cbaf1057
--- /dev/null
+++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/demo/sched/xwork.d
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+self int last;
+
+sched:::wakeup
+/self->last && args[0]->pr_stype == SOBJ_CV/
+{
+ @[stringof(args[1]->pr_fname)] = sum(vtimestamp - self->last);
+ self->last = 0;
+}
+
+sched:::wakeup
+/execname == "Xsun" && self->last == 0/
+{
+ self->last = vtimestamp;
+}