Re: [hackers] [ubase][PATCH] Add vmstat

From: Michael Forney <mforney_AT_mforney.org>
Date: Tue, 5 Nov 2019 12:03:04 -0800

On 2019-11-05, Mattias Andrée <maandree_AT_kth.se> wrote:
> On Sat, 2 Nov 2019 12:33:58 -0700
> Michael Forney <mforney_AT_mforney.org> wrote:
>
>> I've never used vmstat before, but this looks pretty good overall and
>> seems to work well.
>>
>> On 2019-10-05, Mattias Andrée <maandree_AT_kth.se> wrote:
>> > + goto beginning;
>> > + for (; argc && (argc < 2 || i < count); i++) {
>>
>> Why not just set count = 1 when argc < 2?
>
> Because that would stop the loop after 1 iteration.
> If argc == 1, the loop should be infinite.

Oh, right.

> An alternative that would work is:
>
> for (;;) {
> load_vm(&vm[i & 1]);
> print_vm(&vm[i & 1], &vm[~i & 1], active_mem, timestamp, one_header ? !i :
> (i % 50 == 0));
> i++;
> if (!argc || (argc == 2 && i == count))
> break;
> clock_nanosleep(CLOCK_MONOTONIC, 0, &delay, NULL);
> }

FWIW, I like this approach.
Received on Tue Nov 05 2019 - 21:03:04 CET

This archive was generated by hypermail 2.3.0 : Tue Nov 05 2019 - 22:12:25 CET