1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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;
}
|