aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhoon Kim <namhoonk@cs.unc.edu>2015-03-04 09:58:24 -0500
committerNamhoon Kim <namhoonk@cs.unc.edu>2015-03-04 09:58:24 -0500
commita27319a7ffe7f72828faec29c6748453297488a8 (patch)
tree4b07fa177eefa04166edae326267ab16682f1be6
parent6b091698a8c1575d96e6c4e3dd36252cfa7aabd1 (diff)
fixed timer
-rw-r--r--litmus/reservation.c26
-rw-r--r--litmus/sched_mc2.c7
2 files changed, 22 insertions, 11 deletions
diff --git a/litmus/reservation.c b/litmus/reservation.c
index 86d2f6e65382..25e838cb31f9 100644
--- a/litmus/reservation.c
+++ b/litmus/reservation.c
@@ -4,8 +4,8 @@
4#include <litmus/litmus.h> 4#include <litmus/litmus.h>
5#include <litmus/reservation.h> 5#include <litmus/reservation.h>
6 6
7#define TRACE(fmt, args...) do {} while (false) 7//#define TRACE(fmt, args...) do {} while (false)
8#define TRACE_TASK(fmt, args...) do {} while (false) 8//#define TRACE_TASK(fmt, args...) do {} while (false)
9 9
10void reservation_init(struct reservation *res) 10void reservation_init(struct reservation *res)
11{ 11{
@@ -387,15 +387,25 @@ static void gmp_add_event(
387{ 387{
388 struct next_timer_event *nevent, *queued; 388 struct next_timer_event *nevent, *queued;
389 struct list_head *pos; 389 struct list_head *pos;
390 int found = 0; 390 int found = 0, update = 0;
391 391
392 //when = div64_u64(when, TIMER_RESOLUTION); 392 //when = div64_u64(when, TIMER_RESOLUTION);
393 //when *= TIMER_RESOLUTION; 393 //when *= TIMER_RESOLUTION;
394//printk(KERN_ALERT "GMP_ADD id=%d type=%d when=%llu\n", id, type, when); 394//printk(KERN_ALERT "GMP_ADD id=%d type=%d when=%llu\n", id, type, when);
395 nevent = gmp_find_event_by_id(gmp_env, id); 395 nevent = gmp_find_event_by_id(gmp_env, id);
396 396
397 if (!nevent || nevent->type != type) { 397 if (nevent)
398 nevent = kzalloc(sizeof(*nevent), GFP_ATOMIC); 398 TRACE("EVENT R%d update prev = %llu, new = %llu\n", nevent->id, nevent->next_update, when);
399
400 if (nevent && nevent->next_update > when) {
401 list_del(&nevent->list);
402 update = 1;
403
404 }
405
406 if (!nevent || nevent->type != type || update == 1) {
407 if (update == 0)
408 nevent = kzalloc(sizeof(*nevent), GFP_ATOMIC);
399 BUG_ON(!nevent); 409 BUG_ON(!nevent);
400 nevent->next_update = when; 410 nevent->next_update = when;
401 nevent->id = id; 411 nevent->id = id;
@@ -421,9 +431,9 @@ static void gmp_add_event(
421; //printk(KERN_ALERT "EVENT FOUND id = %d type=%d when=%llu, NEW EVENT type=%d when=%llu\n", nevent->id, nevent->type, nevent->next_update, type, when); 431; //printk(KERN_ALERT "EVENT FOUND id = %d type=%d when=%llu, NEW EVENT type=%d when=%llu\n", nevent->id, nevent->type, nevent->next_update, type, when);
422 } 432 }
423 433
424 //TRACE("======START PRINTING EVENT LIST======\n"); 434 TRACE("======START PRINTING EVENT LIST======\n");
425 //gmp_print_events(gmp_env, litmus_clock()); 435 gmp_print_events(gmp_env, litmus_clock());
426 //TRACE("======FINISH PRINTING EVENT LIST======\n"); 436 TRACE("======FINISH PRINTING EVENT LIST======\n");
427} 437}
428 438
429void gmp_add_event_after( 439void gmp_add_event_after(
diff --git a/litmus/sched_mc2.c b/litmus/sched_mc2.c
index f7758f2aff58..0d378c11ae85 100644
--- a/litmus/sched_mc2.c
+++ b/litmus/sched_mc2.c
@@ -170,6 +170,7 @@ static void task_departs(struct task_struct *tsk, int job_complete)
170 ce = &state->crit_entries[lv]; 170 ce = &state->crit_entries[lv];
171 ce->running = tsk; 171 ce->running = tsk;
172 res->is_ghost = 1; 172 res->is_ghost = 1;
173 gmp_add_event_after(&_global_env, res->cur_budget, res->id, EVENT_DRAIN);
173 TRACE_TASK(tsk, "BECOME GHOST at %llu\n", litmus_clock()); 174 TRACE_TASK(tsk, "BECOME GHOST at %llu\n", litmus_clock());
174 175
175 } 176 }
@@ -305,7 +306,7 @@ static void mc2_update_timer_and_unlock(struct mc2_cpu_state *state)
305 litmus_reschedule(cpu); 306 litmus_reschedule(cpu);
306 } 307 }
307 } 308 }
308 } else if (event->next_update < update && event->timer_armed_on == NO_CPU) { 309 } else if (event->next_update < update && (event->timer_armed_on == NO_CPU || event->timer_armed_on == state->cpu)) {
309 event->timer_armed_on = state->cpu; 310 event->timer_armed_on = state->cpu;
310 update = event->next_update; 311 update = event->next_update;
311 break; 312 break;
@@ -484,7 +485,7 @@ static enum hrtimer_restart on_scheduling_timer(struct hrtimer *timer)
484 update = now + remain_budget; 485 update = now + remain_budget;
485 } 486 }
486 487
487 //TRACE_CUR("on_scheduling_timer at %llu, upd:%llu (for cpu=%d) g_schedule_now:%d\n", now, update, state->cpu, global_schedule_now); 488 TRACE_CUR("on_scheduling_timer at %llu, upd:%llu (for cpu=%d) g_schedule_now:%d\n", now, update, state->cpu, global_schedule_now);
488//printk(KERN_ALERT "on_scheduling_timer at %llu, upd:%llu (for cpu=%d) g_schedule_now:%d\n", now, update, state->cpu, global_schedule_now); 489//printk(KERN_ALERT "on_scheduling_timer at %llu, upd:%llu (for cpu=%d) g_schedule_now:%d\n", now, update, state->cpu, global_schedule_now);
489 if (update <= now) { 490 if (update <= now) {
490 litmus_reschedule_local(); 491 litmus_reschedule_local();
@@ -502,7 +503,7 @@ static enum hrtimer_restart on_scheduling_timer(struct hrtimer *timer)
502 raw_spin_lock(&_lowest_prio_cpu.lock); 503 raw_spin_lock(&_lowest_prio_cpu.lock);
503 _lowest_prio_cpu.cpu_entries[cpu].will_schedule = true; 504 _lowest_prio_cpu.cpu_entries[cpu].will_schedule = true;
504 raw_spin_unlock(&_lowest_prio_cpu.lock); 505 raw_spin_unlock(&_lowest_prio_cpu.lock);
505 //TRACE("LOWEST CPU = P%d\n", cpu); 506 TRACE("LOWEST CPU = P%d\n", cpu);
506 litmus_reschedule(cpu); 507 litmus_reschedule(cpu);
507 } 508 }
508 } 509 }