lkml.org 
[lkml]   [1996]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectfake_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;
}
-----------------------



\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.182 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site