/
dasa_nd.c
121 lines (108 loc) · 3.08 KB
/
dasa_nd.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* chronos/dasa_nd.c
*
* DASA_ND Single-Core Scheduler Module for ChronOS
*
* Author(s)
* - Matthew Dellinger, mdelling@vt.edu
*
* Copyright (C) 2009-2012 Virginia Tech Real Time Systems Lab
*/
#include <linux/module.h>
#include <linux/chronos_types.h>
#include <linux/chronos_sched.h>
#include <linux/list.h>
struct rt_info* sched_dasa_nd(struct list_head *head, int flags)
{
struct rt_info *task, *best = local_task(head->next);
struct rt_info *new_schedule=NULL, *prev_schedule = NULL;
list_for_each_entry(task, head, task_list[LOCAL_LIST]){
if(check_task_failure(task, flags))
return task;
initialize_lists(task);
livd(task, false, flags); //updating value density values for all tasks in queue
if(task->local_ivd < best->local_ivd)
best = task;
}
copy_list(task, LOCAL_LIST, SCHED_LIST1);
quicksort(best, SCHED_LIST1, SORT_KEY_LVD, 0);
//best points to task with highest value density
new_schedule = task = best;
while(1) {
prev_schedule = new_schedule;
if (insert_on_list(task, new_schedule, SCHED_LIST2, SORT_KEY_DEADLINE, 0))
new_schedule = task;
if (!list_is_feasible(new_schedule, SCHED_LIST2)){
list_remove(task, SCHED_LIST2);
new_schedule = prev_schedule;
}
//moving to next task
task = task_list_entry(task->task_list[SCHED_LIST1].next, SCHED_LIST1);
if(task == best) //list iteration completed
break;
}
return (new_schedule == NULL) ? best : new_schedule;
}
struct rt_sched_local dasa_nd = {
.base.name = "DASA_ND",
.base.id = SCHED_RT_DASA_ND,
.flags = 0,
.schedule = sched_dasa_nd,
.base.sort_key = SORT_KEY_DEADLINE,
.base.list = LIST_HEAD_INIT(dasa_nd.base.list)
};
/*
struct rt_info* sched_dasa_nd(struct list_head *head, int flags)
{
struct rt_info *task, *temp=NULL, *save_temp, *best = local_task(head->next);
list_for_each_entry(task, head, task_list[LOCAL_LIST]){
if(check_task_failure(task, flags))
return task;
initialize_lists(task);
livd(task, false, flags);
list_add_before(best, task, SCHED_LIST1);
if(task->local_ivd < best->local_ivd)
best = task;
}
quicksort(best, SCHED_LIST1, SORT_KEY_LVD, 0);
task = best;
while(1) {
save_temp = temp;
if(temp == NULL)
temp = task;
else if (insert_on_list(task, temp, SCHED_LIST2, SORT_KEY_DEADLINE, 0))
temp = task;
if (!list_is_feasible(temp, SCHED_LIST2)){
list_remove(task, SCHED_LIST2);
temp = save_temp;
}
task = task_list_entry(task->task_list[SCHED_LIST1].next, SCHED_LIST1);
if(task == best)
break;
}
if(temp)
return temp;
else
return best;
}
struct rt_sched_local dasa_nd = {
.base.name = "DASA_ND",
.base.id = SCHED_RT_DASA_ND,
.flags = 0,
.schedule = sched_dasa_nd,
.base.sort_key = SORT_KEY_DEADLINE,
.base.list = LIST_HEAD_INIT(dasa_nd.base.list)
};
*/
static int __init dasa_nd_init(void)
{
return add_local_scheduler(&dasa_nd);
}
module_init(dasa_nd_init);
static void __exit dasa_nd_exit(void)
{
remove_local_scheduler(&dasa_nd);
}
module_exit(dasa_nd_exit);
MODULE_DESCRIPTION("DASA_ND Single-Core Scheduling Module for ChronOS");
MODULE_AUTHOR("Matthew Dellinger <matthew@mdelling.com>");
MODULE_LICENSE("GPL");