Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/top/machine.c
Show First 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | |||||
static int compare_swap(const void *a, const void *b); | static int compare_swap(const void *a, const void *b); | ||||
static int compare_jid(const void *a, const void *b); | static int compare_jid(const void *a, const void *b); | ||||
static int compare_pid(const void *a, const void *b); | static int compare_pid(const void *a, const void *b); | ||||
static int compare_tid(const void *a, const void *b); | static int compare_tid(const void *a, const void *b); | ||||
static const char *format_nice(const struct kinfo_proc *pp); | static const char *format_nice(const struct kinfo_proc *pp); | ||||
static void getsysctl(const char *name, void *ptr, size_t len); | static void getsysctl(const char *name, void *ptr, size_t len); | ||||
static int swapmode(int *retavail, int *retfree); | static int swapmode(int *retavail, int *retfree); | ||||
static void update_layout(void); | static void update_layout(void); | ||||
static int find_uid(uid_t needle, int *haystack); | |||||
static int | |||||
find_uid(uid_t needle, int *haystack) | |||||
{ | |||||
size_t i = 0; | |||||
for (; i < TOP_MAX_UIDS; ++i) | |||||
if ((uid_t)haystack[i] == needle) | |||||
return 1; | |||||
return 0; | |||||
} | |||||
void | void | ||||
toggle_pcpustats(void) | toggle_pcpustats(void) | ||||
{ | { | ||||
if (ncpus == 1) | if (ncpus == 1) | ||||
return; | return; | ||||
update_layout(); | update_layout(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 557 Lines • ▼ Show 20 Lines | get_process_info(struct system_info *si, struct process_select *sel, | ||||
/* get a pointer to the states summary array */ | /* get a pointer to the states summary array */ | ||||
si->procstates = process_states; | si->procstates = process_states; | ||||
/* set up flags which define what we are going to select */ | /* set up flags which define what we are going to select */ | ||||
show_idle = sel->idle; | show_idle = sel->idle; | ||||
show_jid = sel->jid != -1; | show_jid = sel->jid != -1; | ||||
show_self = sel->self == -1; | show_self = sel->self == -1; | ||||
show_system = sel->system; | show_system = sel->system; | ||||
show_uid = sel->uid != -1; | show_uid = sel->uid[0] != -1; | ||||
show_command = sel->command != NULL; | show_command = sel->command != NULL; | ||||
show_kidle = sel->kidle; | show_kidle = sel->kidle; | ||||
/* count up process states and get pointers to interesting procs */ | /* count up process states and get pointers to interesting procs */ | ||||
total_procs = 0; | total_procs = 0; | ||||
active_procs = 0; | active_procs = 0; | ||||
total_inblock = 0; | total_inblock = 0; | ||||
total_oublock = 0; | total_oublock = 0; | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | for (pp = pbase, i = 0; i < nproc; pp++, i++) { | ||||
if (displaymode == DISP_IO && !show_idle && p_io == 0) | if (displaymode == DISP_IO && !show_idle && p_io == 0) | ||||
/* skip processes that aren't doing I/O */ | /* skip processes that aren't doing I/O */ | ||||
continue; | continue; | ||||
if (show_jid && pp->ki_jid != sel->jid) | if (show_jid && pp->ki_jid != sel->jid) | ||||
/* skip proc. that don't belong to the selected JID */ | /* skip proc. that don't belong to the selected JID */ | ||||
continue; | continue; | ||||
if (show_uid && pp->ki_ruid != (uid_t)sel->uid) | if (show_uid && !find_uid(pp->ki_ruid, sel->uid)) | ||||
/* skip proc. that don't belong to the selected UID */ | /* skip proc. that don't belong to the selected UID */ | ||||
continue; | continue; | ||||
*prefp++ = pp; | *prefp++ = pp; | ||||
active_procs++; | active_procs++; | ||||
} | } | ||||
/* if requested, sort the "interesting" processes */ | /* if requested, sort the "interesting" processes */ | ||||
▲ Show 20 Lines • Show All 762 Lines • Show Last 20 Lines |