Hi there,

        I've been poking at boot-chart a little, to try to understand why each
of my process appears to start by doing nothing ;-) and then often goes
on (on a loaded, CPU bound system) to (apparently) do nothing at regular
intervals. I had assumed this was an artifact of poor rendering,
time-keeping, and/or some other similar issue - and had a dig.

        It seems pybootchartgui (no doubt in keeping with the Java code) does a
number of start_time = min (start_time, other_time) - where other_time
almost always looks less accurate to me than the /proc/[pid]/stat data
(eg. the polling time) - I hacked these out: but no joy.

        I also disabled the use of alpha since if a process is running I'm
interested in seeing that fact, rather than some very pale blue if many
processes are running concurrently - alpha is the proportion of CPU time
it gets - still that gave no useful data: clearly running processes with
great leading holes in them - and no process should (apparently) take
zero CPU for several seconds immediately after startup - surely ?

        After reading the proc_ps output, I began to wonder if the time-keeping
data was any good; and knocked up a little test app, as attached. The
app does some syscalls, and a million or so loop iterations each time
around [ I hope ;-]. My output is something like:

utime 0 stime 0
utime 0 stime 0
utime 0 stime 0
utime 0 stime 0
utime 0 stime 0
utime 0 stime 0
utime 2 stime 0
utime 2 stime 0
utime 2 stime 0
utime 2 stime 0
utime 2 stime 0
utime 2 stime 0
utime 4 stime 0
utime 4 stime 0
utime 4 stime 0
utime 4 stime 0

        It seems like the granularity of the data coming from /proc/[pid]/stat
is rather lower than could be hoped. I had a hack to fs/proc/array.c to
export jiffies instead of clock_t's - but (apparently) that doesn't help
markedly.

        Is there a better, higher resolution way of telling if a process made
any progress ? whether it was scheduled even ?

        Of course sysprof is a great tool for profiling an entire run of the
system; but not that great for visualising changes over time, ordering,
dependencies and so on :-)

        Thanks,

                Michael.

-- 
 [email protected]  <><, Pseudo Engineer, itinerant idiot
#include <stdio.h>
#include <unistd.h>
#include <glib.h>

// Compile with:
//   gcc `pkg-config --cflags --libs glib-2.0` ~/stattest.c && ./a.out

// Test /proc/[pid]/stat
// apparently fields 14, 15 are:
// Amount of time that this process has been scheduled in user mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK).  This
// includes  guest  time,  guest_time (time spent running a virtual CPU, see below), so that applications that are not aware of the
// guest time field do not lose that time from their calculations.


int main(int argc, char **argv)
{
  fprintf (stderr, "sysconf clock tick: %ld\n", sysconf(_SC_CLK_TCK));
  while (1) {
    FILE *file;
    char buffer[4096];
    char *name = g_strdup_printf ("/proc/%d/stat", getpid());
    char **tokens;
    file = fopen (name, "r");
    fgets (buffer, sizeof (buffer), file);
    tokens = g_strsplit (buffer, " ", -1);
    fprintf (stderr, "utime %s stime %s\n", tokens[13], tokens[14]);
    g_strfreev (tokens);
    fclose (file);
    g_free (name);

    {
      volatile int i = 0;
      // consume time:
      for (i = 0; i < 1024 * 1024; i++);
    }
  }
  return 0;
}
_______________________________________________
Moblin dev Mailing List
[email protected]

To manage or unsubscribe from this mailing list visit:
https://lists.moblin.org/mailman/listinfo/dev or your user account on 
http://moblin.org once logged in.

For more information on the Moblin Developer Mailing lists visit:
http://moblin.org/community/mailing-lists

Reply via email to