diff options
Diffstat (limited to 'litmus/sched_edf_hsb.c')
-rw-r--r-- | litmus/sched_edf_hsb.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/litmus/sched_edf_hsb.c b/litmus/sched_edf_hsb.c index c71c00df68df..fcad1072632a 100644 --- a/litmus/sched_edf_hsb.c +++ b/litmus/sched_edf_hsb.c | |||
@@ -239,11 +239,11 @@ static void server_slack_destroy(server_t *donator) | |||
239 | 239 | ||
240 | static void remove_slack(server_t *slack) | 240 | static void remove_slack(server_t *slack) |
241 | { | 241 | { |
242 | if (!slack) | ||
243 | return; | ||
242 | TRACE_SERVER_SUB(slack, "slack removed"); | 244 | TRACE_SERVER_SUB(slack, "slack removed"); |
243 | //sched_trace_action(NULL, SLACK_EXPIRED_ACTION); | 245 | //sched_trace_action(NULL, SLACK_EXPIRED_ACTION); |
244 | 246 | ||
245 | BUG_ON(!slack); | ||
246 | |||
247 | if (head_in_list(&slack->list)) | 247 | if (head_in_list(&slack->list)) |
248 | list_del_init(&slack->list); | 248 | list_del_init(&slack->list); |
249 | slack->deadline = 0; | 249 | slack->deadline = 0; |
@@ -261,8 +261,8 @@ static void add_slack(server_t *slack) | |||
261 | 261 | ||
262 | TRACE_SERVER_SUB(slack, "slack added"); | 262 | TRACE_SERVER_SUB(slack, "slack added"); |
263 | 263 | ||
264 | BUG_ON(head_in_list(&slack->list)); | 264 | if (head_in_list(&slack->list)) |
265 | 265 | return; | |
266 | 266 | ||
267 | list_for_each_prev(pos, &slack_queue) { | 267 | list_for_each_prev(pos, &slack_queue) { |
268 | queued = list_entry(pos, server_t, list); | 268 | queued = list_entry(pos, server_t, list); |
@@ -402,7 +402,8 @@ static noinline server_t* next_eligible_slack_server(void) | |||
402 | BUG_ON(!next_slack); | 402 | BUG_ON(!next_slack); |
403 | 403 | ||
404 | if (lt_after(next_slack->deadline, litmus_clock()) && | 404 | if (lt_after(next_slack->deadline, litmus_clock()) && |
405 | lt_after(next_slack->budget, SLACK_MIN)) { | 405 | lt_after(next_slack->budget, SLACK_MIN) && |
406 | !is_server_linked(next_slack)) { | ||
406 | break; | 407 | break; |
407 | } else { | 408 | } else { |
408 | /* Slack has expired or has too little time */ | 409 | /* Slack has expired or has too little time */ |
@@ -926,7 +927,7 @@ static inline int is_eligible(struct task_struct *task, | |||
926 | hrt_server->ready, hrt_server->no_slack, | 927 | hrt_server->ready, hrt_server->no_slack, |
927 | hrt_server->server.deadline, | 928 | hrt_server->server.deadline, |
928 | get_deadline(task)); | 929 | get_deadline(task)); |
929 | return hrt_server->ready && | 930 | return hrt_server->ready && !is_server_linked(&hrt_server->server) && |
930 | (hrt_server->no_slack || | 931 | (hrt_server->no_slack || |
931 | lt_after_eq(hrt_server->server.deadline, get_deadline(task))); | 932 | lt_after_eq(hrt_server->server.deadline, get_deadline(task))); |
932 | } | 933 | } |
@@ -936,8 +937,10 @@ static inline int is_eligible(struct task_struct *task, | |||
936 | */ | 937 | */ |
937 | static inline void catchup_server(server_t *server, lt_t time) | 938 | static inline void catchup_server(server_t *server, lt_t time) |
938 | { | 939 | { |
939 | lt_t diff = time - server->deadline; | 940 | lt_t diff, sub; |
940 | lt_t sub = diff % server->period; | 941 | |
942 | diff = time - server->deadline; | ||
943 | sub = diff % server->period; | ||
941 | 944 | ||
942 | server_release_at(server, time - sub); | 945 | server_release_at(server, time - sub); |
943 | TRACE_SERVER_SUB(server, "catching up to %llu", time); | 946 | TRACE_SERVER_SUB(server, "catching up to %llu", time); |
@@ -1105,6 +1108,9 @@ static noinline struct task_struct* next_eligible_srt(void) | |||
1105 | if (!done) { | 1108 | if (!done) { |
1106 | remove(&srt_domain, next_srt); | 1109 | remove(&srt_domain, next_srt); |
1107 | __add_ready(&srt_domain, next_srt); | 1110 | __add_ready(&srt_domain, next_srt); |
1111 | } else if (is_server_linked(task_srt_server(next_srt))){ | ||
1112 | remove(&srt_domain, next_srt); | ||
1113 | done = 0; | ||
1108 | } | 1114 | } |
1109 | } else { | 1115 | } else { |
1110 | done = 1; | 1116 | done = 1; |
@@ -1128,9 +1134,20 @@ static noinline server_t* next_eligible_be_server(void) | |||
1128 | /* Catch up any late be servers. This happens when the servers could | 1134 | /* Catch up any late be servers. This happens when the servers could |
1129 | * not find tasks to schedule or if the system is overutilized. | 1135 | * not find tasks to schedule or if the system is overutilized. |
1130 | */ | 1136 | */ |
1131 | while (be_server && lt_before_eq(be_server->deadline, now)) { | 1137 | while (be_server && (lt_before_eq(be_server->deadline, now) || |
1138 | is_server_linked(be_server))) { | ||
1139 | if (!be_server->deadline) { | ||
1140 | TRACE_SERVER_SUB(be_server, "not intialized"); | ||
1141 | return NULL; | ||
1142 | } | ||
1132 | bheap_delete(server_order, &be_ready_servers, | 1143 | bheap_delete(server_order, &be_ready_servers, |
1133 | be_server->hn); | 1144 | be_server->hn); |
1145 | |||
1146 | if (is_server_linked(be_server)) { | ||
1147 | TRACE_SERVER_SUB(be_server, "linked"); | ||
1148 | continue; | ||
1149 | } | ||
1150 | |||
1134 | catchup_server(be_server, now); | 1151 | catchup_server(be_server, now); |
1135 | check_donate_slack(be_server, NULL); | 1152 | check_donate_slack(be_server, NULL); |
1136 | bheap_insert(server_order, &be_ready_servers, | 1153 | bheap_insert(server_order, &be_ready_servers, |
@@ -1141,6 +1158,7 @@ static noinline server_t* next_eligible_be_server(void) | |||
1141 | } | 1158 | } |
1142 | 1159 | ||
1143 | if (be_server && lt_before(now, be_server->release)) { | 1160 | if (be_server && lt_before(now, be_server->release)) { |
1161 | TRACE_SERVER_SUB(be_server, "not released"); | ||
1144 | be_server = NULL; | 1162 | be_server = NULL; |
1145 | } | 1163 | } |
1146 | 1164 | ||
@@ -1734,6 +1752,7 @@ static void server_completed(server_t *server, struct task_struct *task) | |||
1734 | cpu_entry_t *entry = task_linked_entry(task); | 1752 | cpu_entry_t *entry = task_linked_entry(task); |
1735 | 1753 | ||
1736 | BUG_ON(entry->linked != task); | 1754 | BUG_ON(entry->linked != task); |
1755 | BUG_ON(entry->linked_server != server); | ||
1737 | 1756 | ||
1738 | if (server->type == S_SRT) { | 1757 | if (server->type == S_SRT) { |
1739 | TRACE_TASK_SUB(task, "must wait on server"); | 1758 | TRACE_TASK_SUB(task, "must wait on server"); |
@@ -1873,6 +1892,7 @@ static int admit_be_server(unsigned long long wcet, | |||
1873 | 1892 | ||
1874 | list_add(&be_server->list, &be_servers); | 1893 | list_add(&be_server->list, &be_servers); |
1875 | bheap_insert(server_order, &be_ready_servers, be_server->hn); | 1894 | bheap_insert(server_order, &be_ready_servers, be_server->hn); |
1895 | |||
1876 | out: | 1896 | out: |
1877 | return rv; | 1897 | return rv; |
1878 | } | 1898 | } |
@@ -2016,8 +2036,8 @@ static void start_servers(lt_t time) | |||
2016 | list_for_each(pos, &be_servers) { | 2036 | list_for_each(pos, &be_servers) { |
2017 | be_server = list_entry(pos, server_t, list); | 2037 | be_server = list_entry(pos, server_t, list); |
2018 | 2038 | ||
2019 | BUG_ON(bheap_node_in_heap(be_server->hn)); | 2039 | if (!bheap_node_in_heap(be_server->hn)) |
2020 | bheap_insert(server_order, &be_ready_servers, be_server->hn); | 2040 | bheap_insert(server_order, &be_ready_servers, be_server->hn); |
2021 | 2041 | ||
2022 | /* Cause a catchup later */ | 2042 | /* Cause a catchup later */ |
2023 | server_release_at(be_server, time - be_server->period); | 2043 | server_release_at(be_server, time - be_server->period); |