-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_generator.c
43 lines (41 loc) · 1.22 KB
/
test_generator.c
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
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define null 0
struct processData
{
int arrivaltime;
int priority;
int runningtime;
int id;
int memsize;
};
int main(int argc, char *argv[])
{
char *testnum = argv[1];
FILE *pFile;
strcat(testnum, ".txt");
char name[] = "testcases/processes_";
strcat(name, testnum);
pFile = fopen(name, "w");
int no;
struct processData pData;
printf("Please enter the number of processes you want to generate: ");
scanf("%d", &no);
srand(time(null));
fprintf(pFile, "#id arrival runtime priority memsize\n");
pData.arrivaltime = 1;
for (int i = 1; i <= no; i++)
{
//generate Data Randomly
//[min-max] = rand() % (max_number + 1 - minimum_number) + minimum_number
pData.id = i;
pData.arrivaltime += rand() % (11); //processes arrives in order
pData.runningtime = rand() % (30) + 1;
pData.priority = rand() % (11);
pData.memsize = (rand() % 256) + 1;
fprintf(pFile, "%d\t%d\t%d\t%d\t%d\n", pData.id, pData.arrivaltime, pData.runningtime, pData.priority, pData.memsize);
}
fclose(pFile);
}