/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by David Laight.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
void
showsyscall(void)
{
int i, ii, l, c;
uint64_t v;
static int failcnt = 0;
static int relabel = 0;
uint64_t itime;
if (relabel) {
labelsyscall();
relabel = 0;
}
cpuswap();
if (display_mode == TIME) {
if (toofast(&failcnt))
return;
} else
etime = 1.0;
itime = etime * 100;
failcnt = 0;
show_vmstat_top(&s.Total, &s.uvmexp, &s1.uvmexp);
/* Sort out the values we are going to display */
for (i = 0; i < (int)__arraycount(s.counts); i++) {
switch (show) {
default:
case SHOW_COUNTS:
v = s.counts[i] - s1.counts[i];
break;
case SHOW_TIMES:
v = s.times[i] - s1.times[i];
break;
case SHOW_COUNTS | SHOW_TIMES: /* time/count */
v = s.counts[i] - s1.counts[i];
v = v ? (s.times[i] - s1.times[i]) / v : 0;
}
if (display_mode == TIME)
v = (v * 100 + itime/2) / itime;
val[i] = v;
/*
* We use an 'infinite response filter' in a vague
* attempt to stop the data leaping around too much.
* I suspect there are other/better methods in use.
*/
if (irf_first) {
irf[i] = v;
irf_first = 0;
} else {
irf[i] = irf[i] * 7 / 8 + v;
}
}
/* Undo all the sorting */
for (i = 0; i < (int)__arraycount(syscall_sort); i++)
syscall_sort[i] = i;
if (sort_order == NAMES) {
/* Only sort the entries we have names for */
qsort(syscall_sort, __arraycount(syscallnames), sizeof syscall_sort[0],
compare_names);
}
return;