-
Notifications
You must be signed in to change notification settings - Fork 6
/
policy_fixed.c
56 lines (47 loc) · 919 Bytes
/
policy_fixed.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
55
56
#include "simrts.h"
#define MAX_TASKS 1000
typedef struct {
unsigned mem_idx, cpufreq_idx;
} task_info_t;
static task_info_t task_infos[MAX_TASKS];
static BOOL
fixed_init(void)
{
FILE *fp;
char buf[1024];
int n = 0;
fp = fopen("task.txt", "r");
if (fp == NULL)
return FALSE;
while (fgets(buf, 1024, fp)) {
if (buf[0] == '#')
continue;
if (sscanf(buf, "%u %u", &task_infos[n].mem_idx, &task_infos[n].cpufreq_idx) != 2) {
fclose(fp);
return FALSE;
}
n++;
}
fclose(fp);
return TRUE;
}
static BOOL
fixed_assign_task(task_t *task)
{
task_info_t *info = task_infos + (task->no - 1);
task->idx_cpufreq = info->cpufreq_idx + 1;
return assign_mem(task, info->mem_idx + 1);
}
static BOOL
fixed_reassign_task(task_t *task)
{
return TRUE;
}
policy_t policy_fixed = {
"fixed",
"Fixed memory type & CPU frequency(fixed)",
FALSE,
fixed_init,
fixed_assign_task,
fixed_reassign_task
};