diff options
author | bhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b> | 2008-08-29 23:06:10 +0000 |
---|---|---|
committer | bhackerozzo <bhackerozzo@3b445381-d045-0410-9223-e17ecdb95f4b> | 2008-08-29 23:06:10 +0000 |
commit | 7fb5991fe92577f682a1bcb115bbf39f781c2697 (patch) | |
tree | 636883705996a92f983f7cc3d63095930c085dfc | |
parent | 8a34fa7c47579002e7e599fc7d7c8ecc2e316ce3 (diff) | |
download | cpulimit-7fb5991fe92577f682a1bcb115bbf39f781c2697.tar.gz |
ptest deleted
-rw-r--r-- | ptest.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/ptest.c b/ptest.c deleted file mode 100644 index ee85a2a..0000000 --- a/ptest.c +++ /dev/null @@ -1,59 +0,0 @@ -#include <stdio.h> -#include <sys/types.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <stdlib.h> -#include <unistd.h> - -#define N 8 - -//simple program to test cpulimit -int main() -{ - printf("Parent: PID %d\n", getpid()); - getchar(); - sleep(1); - while(1); - int i; - int children[N]; - for (i=0;i<N;i++) { - int pid = fork(); - if (pid>0) { - //parent code - children[i] = pid; - printf("Child %d created\n", pid); - } - else if (pid==0) { - while(1); - //child code -// while(1) { - //random generator initialization - struct timeval t; - gettimeofday(&t, NULL); - srandom(t.tv_sec + t.tv_usec + getpid()); - int loop = random() % 1000000; - printf("start\n"); - int i,j; - for (i=0;i<1000;i++) - for (j=0;j<loop;j++); - printf("stop\n"); - int time = random() % 10000000; - // printf("Child %d wait %d\n", getpid(), time); - usleep(time); - printf("Child %d terminated\n", getpid()); -// } - exit(0); - } - else { - fprintf(stderr, "fork() failed!\n"); - } - } - for (i=0;i<N;i++) { - int status; - waitpid(children[i], &status, 0); - } - sleep(1); - return 0; -} |