/* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * This D script is used as an example in the Solaris Dynamic Tracing Guide * wiki in the "sched Provider" Chapter. * * The full text of the this chapter may be found here: * * http://docs.oracle.com/cd/E36784_01/html/E36846/sched-provider.html * * On machines that have DTrace installed, this script is available as * whatfor.d in /usr/demo/dtrace, a directory that contains all D scripts * used in the Solaris Dynamic Tracing Guide. A table of the scripts and their * corresponding chapters may be found here: * * file:///usr/demo/dtrace/index.html */ 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; }