help-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wait3 Questions


From: Brent A. Fulgham
Subject: Wait3 Questions
Date: Tue, 21 Aug 2001 20:12:38 -0700
User-agent: Mutt/1.3.20i

I started taking a look at the "time" package, which fails when
autobuilding due to some configure tests related to the wait3
library command.

Under Linux, this command blocks on a child process, then returns
with some statistics about the child process.

Take, for example, the test program I cribbed from the configure
script for 'time':

=======================End Program============================
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
/* HP-UX has wait3 but does not fill in rusage at all.  */
main() {
  struct rusage r;
  int i;
  /* Use a field that we can force nonzero --
     voluntary context switches.
     For systems like NeXT and OSF/1 that don't set it,
     also use the system CPU time.  And page faults (I/O) for Linux.  */
     r.ru_nvcsw = 0;
     r.ru_stime.tv_sec = 0;
     r.ru_stime.tv_usec = 0;
     r.ru_majflt = r.ru_minflt = 0;
     switch (fork()) {
         case 0: /* Child.  */
           printf("Child...\n");
           sleep(1); /* Give up the CPU.  */
           printf("Child done.\n");
           _exit(0);
         case -1: _exit(0); /* What can we do?  */
         default: /* Parent.  */
           printf("Parent...\n");
           wait3(&i, 0, &r);
           sleep(2); /* Avoid "text file busy" from rm on fast HP-UX machines.  
*/
           printf("Found: nvcsw=%f, pagflt=%f, minflt=%f\n", r.ru_nvcsw,
                        r.ru_majflt, r.ru_minflt);
           exit(r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
                    && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
    }
}

=======================End Program============================

Under Linux, I get information that includes some voluntary
page faults, generated by the sleep() statement allowing
the parent to give up its processing slice.

bfulgham@hopper:~$ ./wait3
Parent...
Child...
Child done.
Found: nvcsw=0.000000, pagflt=2.081255, minflt=2.166260
bfulgham@hopper:~$

Under the Hurd, I get very different behavior -- no page
faults are reported:

Parent...
Child...
Child done.
Found: nvcsw=0.000000, pagflt=0.000000, minflt=0.000000

Is this behavior expected -- i.e., does the Hurd handle
swapping, etc., so differently that we would not expect
any statistics from Wait3 in this case?  Or does this
indicate a bug in the Hurd code?

Thanks,

-Brent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]