diff options
| author | klaar36 <klas.arvidsson@liu.se> | 2015-03-20 17:30:24 +0100 |
|---|---|---|
| committer | klaar36 <klas.arvidsson@liu.se> | 2015-03-20 17:30:24 +0100 |
| commit | e7bc50ca8ffcaa6ed68ebd2315f78b0f5a7d10ad (patch) | |
| tree | 4de97af7207676b69cb6a9aba8cb443cc134855d /src/examples/longrun_interactive.c | |
| parent | b0418a24e709f0632d2ede5b0f327c422931939b (diff) | |
| download | pintos-rs-e7bc50ca8ffcaa6ed68ebd2315f78b0f5a7d10ad.tar.gz | |
Initial Pintos
Diffstat (limited to 'src/examples/longrun_interactive.c')
| -rw-r--r-- | src/examples/longrun_interactive.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/examples/longrun_interactive.c b/src/examples/longrun_interactive.c new file mode 100644 index 0000000..0e871bf --- /dev/null +++ b/src/examples/longrun_interactive.c @@ -0,0 +1,77 @@ +/* klaar@ida + + pintos -v -k --fs-disk=2 --qemu -p ../examples/longrun_interactive -a interactive -p ../examples/generic_parent -a generic_parent -p ../examples/busy -a dummy -- -f -q run 'interactive 10 50' + + NOTE: pintos have a limit on file-name length! + + Start a lot of processes and let them finish to test if we + eventually run out of process slots. + To run the test effectively, if you have a limit on number of + processes, lower the limit to 5 processes and run this test like + + 'longrun 5 400' + + It will fill (and if it works empty) your process table 400 times + :-) + + Note that some pintos tests requires at least 16 simultaneous + processes to work, so be sure to increase the limit before running + pintos tests. + */ + +#include <syscall.h> +#include <stdlib.h> +#include <stdio.h> + +#define MAX_SIMULTANEOUS 50 +#define MAX_REPEAT 1000 +#define BUF_SIZE 64 + +int main(int argc, char* argv[]) +{ + char cmd[BUF_SIZE]; + unsigned j = 0; + unsigned simul = 0; + unsigned repeat = 0; + + if (argc != 3) + { + printf("Usage: %s simultaneous repeat\n" + "Where 'simultaneous' is the number of simultaneous processes to \n" + "start and wait for, and 'repeat' how many times this should be \n" + "repeated.\n", argv[0] + ); + return -1; + } + + simul = atoi(argv[1]); + repeat = atoi(argv[2]); + + if (simul > MAX_SIMULTANEOUS) + { + printf("This test program is compiled with a limitation to max %d \n" + "simultaneos processes.\n", MAX_SIMULTANEOUS); + return -1; + } + + if (repeat > MAX_REPEAT) + { + printf("This test program is compiled with a limitation to max %d \n" + "repetitions.\n", MAX_REPEAT); + return -1; + } + + printf("Will try to start a total of %d processes in groups of %d\n", + simul * repeat, simul); + + for (j = 0; j < repeat; ++j) + { + char buf; + snprintf(cmd, BUF_SIZE, "generic_parent %s %i %i", "dummy", j*simul, simul); + wait(exec(cmd)); + + printf("Press ENTER to continue...\n"); + read(STDIN_FILENO, &buf, 1); + } + return 0; +} |
