static procstat_t *list_head_g = NULL;
+static _Bool want_init = 1;
static _Bool report_ctx_switch = 0;
#if HAVE_THREAD_INFO
return (0);
} /* int ps_list_match */
-static void ps_update_counter (_Bool init, derive_t *group_counter,
+static void ps_update_counter (derive_t *group_counter,
derive_t *curr_counter, derive_t new_counter)
{
unsigned long curr_value;
- if (init)
+ if (want_init)
+ {
+ *curr_counter = new_counter;
return;
+ }
if (new_counter < *curr_counter)
curr_value = new_counter + (ULONG_MAX - *curr_counter);
for (procstat_t *ps = list_head_g; ps != NULL; ps = ps->next)
{
- _Bool want_init;
-
if ((ps_list_match (name, cmdline, ps)) == 0)
continue;
ps->cswitch_vol += ((pse->cswitch_vol == -1)?0:pse->cswitch_vol);
ps->cswitch_invol += ((pse->cswitch_invol == -1)?0:pse->cswitch_invol);
- want_init = (entry->vmem_minflt_counter == 0)
- && (entry->vmem_majflt_counter == 0);
- ps_update_counter (want_init,
+ ps_update_counter (
&ps->vmem_minflt_counter,
&pse->vmem_minflt_counter,
entry->vmem_minflt_counter);
- ps_update_counter (want_init,
+ ps_update_counter (
&ps->vmem_majflt_counter,
&pse->vmem_majflt_counter,
entry->vmem_majflt_counter);
- want_init = (entry->cpu_user_counter == 0)
- && (entry->cpu_system_counter == 0);
- ps_update_counter (want_init,
+ ps_update_counter (
&ps->cpu_user_counter,
&pse->cpu_user_counter,
entry->cpu_user_counter);
- ps_update_counter (want_init,
+ ps_update_counter (
&ps->cpu_system_counter,
&pse->cpu_system_counter,
entry->cpu_system_counter);
read_fork_rate();
#endif /* KERNEL_SOLARIS */
+ want_init = 0;
+
return (0);
} /* int ps_read */