forked from oslab-ewha/memwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
policy_hm_chk.c
47 lines (41 loc) · 849 Bytes
/
policy_hm_chk.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
#include "simrts.h"
static BOOL
hm_chk_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
hm_chk_reassign_task(task_t *task)
{
mem_type_t mem_types_try[] = { MEMTYPE_NVRAM, MEMTYPE_DRAM };
double power;
int i;
power = calc_task_power_consumed(task);
revoke_mem(task);
for (i = 0; i < 2; i++) {
if (assign_mem(task, mem_types_try[i])) {
calc_task_det(task);
if (calc_task_power_consumed(task) <= power) {
if (is_schedulable(task))
return TRUE;
}
revert_task_det(task);
}
}
return FALSE;
}
policy_t policy_hm_chk = {
"hm_chk",
"checked hybrid memory(hm_chk)",
FALSE,
NULL,
hm_chk_assign_task,
hm_chk_reassign_task
};