first pass at a load-generating program. works, but needs to be

parameterized for happiness.
This commit is contained in:
lindes 2001-08-08 20:55:47 +00:00
parent dd93ba15d2
commit 76af8d3b3d
3 changed files with 38 additions and 1 deletions

View File

@ -1 +1,2 @@
ttyload
loader

View File

@ -18,7 +18,7 @@ VERSION = -DVERSION='"'`cat Version`'"'
CFLAGS = $(INCLUDES) $(OTHER_FLAGS) $(DEBUG) $(VERSION)
default: archbuild
default: archbuild loader
test: archbuild
./ttyload -i 1

36
loader.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv)
{
int ttl, /* how long to load things */
forks; /* how many jobs to run at once */
time_t start; /* when we started */
pid_t pid; /* return value for fork() */
/* for now, set these purely by hand... later, I'll
* make 'em be based on argv. */
ttl = 90;
forks = 11; /* this one goes to 11. ;-) */
for(/*pre-initted*/; --forks > 0 ;)
{
if(pid = fork())
break; /* don't continue this loop as child. */
}
printf("Bomb running for %d seconds\n", ttl);
start = time(NULL);
while(time(NULL) < (start + ttl))
{
; /* do nothing, tight loop is intentional. */
}
printf("Bomb ending at %ld, started %ld\n", time(NULL), start);
exit(0);
}