#!/usr/sbin/dtrace -Cs #pragma D option quiet int tsexp, rtexp, fxexp, csw; int csw_sec, tsexp_sec, rtexp_sec, fxexp_sec; swtch:entry { csw++; csw_sec++; } fbt:TS:ts_preempt:entry / ((tsproc_t *)args[0]->t_cldata)->ts_timeleft == 0 / { tsexp++; tsexp_sec++; @tsx[execname, tid] = count(); } rt_preempt:entry / ((rtproc_t *)args[0]->t_cldata)->rt_timeleft == 0 / { rtexp++; rtexp_sec++; @rtx[execname, tid] = count(); } fx_preempt:entry / ((fxproc_t *)args[0]->t_cldata)->fx_timeleft == 0 / { fxexp++; fxexp_sec++; @fxx[execname, tid] = count(); } tick-1sec { printf("Context switches in the last second: %d\n",csw_sec); printf("TS time quantum expirations in the last second: %d\n",tsexp_sec); printf("RT time quantum expirations in the last second: %d\n",rtexp_sec); printf("FX time quantum expirations in the last second: %d\n",fxexp_sec); printf("\n\n"); csw_sec = 0; tsexp_sec = 0; rtexp_sec = 0; fxexp_sec = 0; } END { printf("\n\nTotal context switches: %d\n",csw); printf("Total TS time quantum expired: %d\n\n",tsexp); printf("TS time quantum expired...\n"); printf("%-16s %-8s %-8s\n","NAME","TID","CNT"); printa("%-16s %-8d %-8@d\n",@tsx); printf("\n"); printf("Total RT time quantum expired: %d\n\n",rtexp); printf("RT time quantum expired...\n"); printf("%-16s %-8s %-8s\n","NAME","TID","CNT"); printa("%-16s %-8d %-8@d\n",@rtx); printf("\n"); printf("Total FX time quantum expired: %d\n\n",fxexp); printf("FX time quantum expired...\n"); printf("%-16s %-8s %-8s\n","NAME","TID","CNT"); printa("%-16s %-8d %-8@d\n",@fxx); }