-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf_gasgen.c
54 lines (49 loc) · 1.13 KB
/
conf_gasgen.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
44
45
46
47
48
49
50
51
52
53
54
#include "gastask.h"
extern unsigned wcet_min, wcet_max, mem_total;
extern double util_cpu, util_target;
extern unsigned n_tasks_target;
static void
parse_gentask(FILE *fp)
{
char buf[1024];
while (fgets(buf, 1024, fp)) {
if (buf[0] == '#')
continue;
if (buf[0] == '\n' || buf[0] == '*') {
fseek(fp, -1 * strlen(buf), SEEK_CUR);
return;
}
if (sscanf(buf, "%u %u %u %lf %lf %u", &wcet_min, &wcet_max, &mem_total,
&util_cpu, &util_target, &n_tasks_target) != 6) {
FATAL(2, "cannot load configuration: invalid gentask parameters: %s", trim(buf));
}
if (util_cpu > util_target) {
FATAL(2, "target utilization cannot be smaller than full utilzation");
}
}
}
void
parse_conf(FILE *fp)
{
char buf[1024];
while (fgets(buf, 1024, fp)) {
if (buf[0] == '\n' || buf[0] == '#')
continue;
switch (check_section(buf)) {
case SECT_GENETIC:
case SECT_CPUFREQ:
case SECT_TASK:
skip_section(fp);
break;
case SECT_MEM:
parse_mem(fp);
break;
case SECT_GENTASK:
parse_gentask(fp);
break;
default:
errmsg("unknown section: %s", trim(buf));
FATAL(2, "cannot load configuration");
}
}
}