Messages in this thread | | | Date | Thu, 25 Apr 1996 14:18:10 +0200 (MET DST) | From | Henrik Wallin <> | Subject | fake_load |
| |
Hello, everybody!
This program forks itself 20 times and every process calls select with empty parameters except for a small timeout value. (==usleep() I think.) This results in a increasing load. (For me up to 6-7.) But the interesting thing is that according to 'ps', 'procinfo' etc, these processes are 'sleeping', CPU-use is minimal and system+user time is almost zero!!! And the system is working as if it had load near 0.
This behavior changed around 1.3.77.
One can see similar behavior with programs that uses the xforms-library. (xosview, xwatch etc) If I start 5-10 xwatch I get this 'fake_load' behavior. With one xwatch my xload was stuck around 1.
Obvious questions: Why this behaviour ? Is it a bug, or a unpleasant 'feature' ?
/ Henrik Wallin, henrik@triton.campus.luth.se
----------------------- > gcc -o fake_load fake_load.c ----------------------- #include <stdio.h> #include <unistd.h> #include <signal.h> #include <time.h> #include <sys/time.h> #include <sys/types.h>
void quit(int sig) { kill(-getpgrp(), SIGTERM); }
int main(void) { struct timeval tv; int i; signal(SIGINT, quit); signal(SIGTERM, quit);
for(i = 0 ; i < 20 ; i++) { if(fork() == 0) { while(1) { tv.tv_sec = 0; tv.tv_usec = 15000; select(1, NULL, NULL, NULL, &tv); } } } pause(); return 0; } -----------------------
| |