-
Notifications
You must be signed in to change notification settings - Fork 6
/
policy_dvshm_greedy.c
63 lines (53 loc) · 1.1 KB
/
policy_dvshm_greedy.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
57
58
59
60
61
62
63
#include "simrts.h"
static BOOL *reassign_done;
static BOOL
dvshm_greedy_init(void)
{
reassign_done = (BOOL *)calloc(n_tasks, sizeof(BOOL));
return TRUE;
}
static BOOL
dvshm_greedy_assign_task(task_t *task)
{
mem_type_t mem_types_try[] = { MEMTYPE_DRAM, MEMTYPE_NVRAM };
int i;
task->idx_cpufreq = 1;
for (i = 0; i < 2; i++) {
if (assign_mem(task, mem_types_try[i]))
return TRUE;
}
return FALSE;
}
static BOOL
dvshm_greedy_reassign_task(task_t *task)
{
mem_type_t mem_types_try[] = { MEMTYPE_NVRAM, MEMTYPE_DRAM };
int i;
if (reassign_done[task->no - 1])
return TRUE;
revoke_mem(task);
for (i = 0; i < 2; i++) {
if (assign_mem(task, mem_types_try[i])) {
int j;
for (j = n_cpufreqs; j > 0; j--) {
task->idx_cpufreq = j;
calc_task_det(task);
if (is_schedulable(task)) {
reassign_done[task->no - 1] = TRUE;
return TRUE;
}
revert_task_det(task);
}
revoke_mem(task);
}
}
return FALSE;
}
policy_t policy_dvshm_greedy = {
"dvshm_gr",
"DVS with hm by greedy(dvshm-gr)",
FALSE,
dvshm_greedy_init,
dvshm_greedy_assign_task,
dvshm_greedy_reassign_task
};