diff options
author | Tanya Amert <tamert@cs.unc.edu> | 2020-10-18 10:03:29 -0400 |
---|---|---|
committer | Tanya Amert <tamert@cs.unc.edu> | 2020-10-18 10:03:29 -0400 |
commit | 04c02d288b4f5980410ac14c11beea18798a0c16 (patch) | |
tree | 63867a15c04605de43713d2a1a90446494c3bfa1 | |
parent | a9043855f38dab6077b1c62fafb14e5ee1d05371 (diff) |
Still working on global FZs (hard-coded at 100ms), waking up not always working.
-rw-r--r-- | litmus/reservations/gedf_reservation.c | 79 |
1 files changed, 35 insertions, 44 deletions
diff --git a/litmus/reservations/gedf_reservation.c b/litmus/reservations/gedf_reservation.c index 31142253783c..11d1e295b974 100644 --- a/litmus/reservations/gedf_reservation.c +++ b/litmus/reservations/gedf_reservation.c | |||
@@ -586,23 +586,22 @@ static void gedf_env_resume( | |||
586 | #ifdef CONFIG_LITMUS_LOCKING | 586 | #ifdef CONFIG_LITMUS_LOCKING |
587 | // Only the first cpu to resume should wake up forbidden-zone waiters | 587 | // Only the first cpu to resume should wake up forbidden-zone waiters |
588 | if (!tmp_cpus) { | 588 | if (!tmp_cpus) { |
589 | // printk("[%u] About to check for waiters.\n", gedf_env->env.res->id); | 589 | // if (gedf_env->env.res->id == 1) |
590 | // printk("[%u] About to check for waiters.\n", gedf_env->env.res->id); | ||
590 | 591 | ||
591 | // // Wake up any forbidden-zone waiters | 592 | // Wake up any forbidden-zone waiters |
592 | // spin_lock_irqsave(&gedf_env->fz_waiters.lock, flags); | 593 | spin_lock_irqsave(&gedf_env->fz_waiters.lock, flags); |
593 | 594 | ||
594 | // struct task_struct *next; | 595 | struct task_struct *next; |
595 | // while ((next) = __waitqueue_remove_first(&gedf_env->fz_waiters)) { | 596 | while ((next) = __waitqueue_remove_first(&gedf_env->fz_waiters)) { |
596 | // printk("[%u] Waking up process %d.\n", gedf_env->env.res->id, next->pid); | 597 | printk("[%u] Waking up process %d, state=%d.\n", gedf_env->env.res->id, next->pid, next->state); |
597 | // wake_up_process(next); | 598 | if (wake_up_process(next)) |
598 | // } | 599 | printk("[%u] Success waking up %d.\n", gedf_env->env.res->id, next->pid); |
599 | 600 | else | |
600 | // // if (waitqueue_active(&gedf_env->fz_waiters)) { | 601 | printk("[%u] Failed to wake up %d.\n", gedf_env->env.res->id, next->pid); |
601 | // // printk("About to wake up fz waiters\n"); | 602 | } |
602 | // // __wake_up(&gedf_env->fz_waiters, TASK_NORMAL, 0, NULL); // 0: all | ||
603 | // // } | ||
604 | 603 | ||
605 | // spin_unlock_irqrestore(&gedf_env->fz_waiters.lock, flags); | 604 | spin_unlock_irqrestore(&gedf_env->fz_waiters.lock, flags); |
606 | } | 605 | } |
607 | #endif | 606 | #endif |
608 | } | 607 | } |
@@ -1033,53 +1032,45 @@ int gedf_env_omlp_lock(struct litmus_lock* l) | |||
1033 | tsk_rt(t)->num_locks_held++; | 1032 | tsk_rt(t)->num_locks_held++; |
1034 | 1033 | ||
1035 | /* if in a forbidden zone, wait until the next time slice */ | 1034 | /* if in a forbidden zone, wait until the next time slice */ |
1036 | // remaining_component_budget = t_res->par_env->res->cur_budget; | 1035 | /* note that we can't use t_res->par_env->res->cur_budget |
1037 | 1036 | * because it is only updated on a call to schedule(), and | |
1038 | // LOCK STUFFZ | 1037 | * thus might not reflect the current remaining budget |
1039 | 1038 | * for the component */ | |
1040 | unsigned int cpu = smp_processor_id(); | ||
1041 | struct reservation *comp_res = t_res->par_env->res; | ||
1042 | struct mtd_reservation *mtd_res = container_of(comp_res, struct mtd_reservation, res[cpu]); | ||
1043 | BUG_ON(&(mtd_res->res[cpu]) != comp_res); | ||
1044 | gedf_env = container_of(t_res->par_env, struct gedf_reservation_environment, env); | 1039 | gedf_env = container_of(t_res->par_env, struct gedf_reservation_environment, env); |
1045 | printk("%d Getting interval end for component %u on CPU %u (mtd=%p, comp_res=%p)\n", | 1040 | spin_lock_irqsave(&gedf_env->fz_waiters.lock, flags); |
1046 | t->pid, gedf_env->env.res->id, cpu, mtd_res, comp_res); | ||
1047 | 1041 | ||
1048 | lt_t interval_end = mtd_res->cur_interval[cpu].end; | 1042 | unsigned int cpu = smp_processor_id(); |
1049 | lt_t major_cycle_start = mtd_res->major_cycle_start[cpu]; | 1043 | struct mtd_reservation *mtd_res = (struct mtd_reservation*)t_res->par_env->res; |
1050 | lt_t timeslice_end = interval_end + major_cycle_start; | 1044 | lt_t timeslice_end = mtd_res->cur_interval[cpu].end + mtd_res->major_cycle_start[cpu]; |
1051 | lt_t current_time = litmus_clock(); | 1045 | remaining_component_budget = timeslice_end - litmus_clock(); |
1052 | remaining_component_budget = timeslice_end - current_time; | ||
1053 | printk("%d Interval end=%llu, major cycle start=%llu, timeslice end=%llu, current time=%llu, budget=%llu\n", | ||
1054 | t->pid, interval_end, major_cycle_start, timeslice_end, current_time, remaining_component_budget); | ||
1055 | 1046 | ||
1056 | fz_length = 100 * 1000000LL; // for now, hard-coded at 100ms | 1047 | fz_length = 100 * 1000000LL; // for now, hard-coded at 100ms |
1057 | if (remaining_component_budget < fz_length) { | 1048 | if (remaining_component_budget < fz_length) { |
1058 | // gedf_env = container_of(t_res->par_env, struct gedf_reservation_environment, env); | ||
1059 | |||
1060 | /* go on a wait queue to be woken up when the parent reservation | 1049 | /* go on a wait queue to be woken up when the parent reservation |
1061 | * is next scheduled */ | 1050 | * is next scheduled */ |
1062 | // spin_lock_irqrestore(&gedf_env->fz_waiters.lock, flags); | ||
1063 | |||
1064 | printk("%d in the forbidden zone, going on wait queue (budget left: %llu)\n", | 1051 | printk("%d in the forbidden zone, going on wait queue (budget left: %llu)\n", |
1065 | t->pid, remaining_component_budget); | 1052 | t->pid, remaining_component_budget); |
1066 | 1053 | ||
1067 | // init_waitqueue_entry(&fz_wait, t); | 1054 | init_waitqueue_entry(&fz_wait, t); |
1068 | // set_task_state(t, TASK_UNINTERRUPTIBLE); | 1055 | set_task_state(t, TASK_UNINTERRUPTIBLE); |
1069 | // __add_wait_queue_tail_exclusive(&gedf_env->fz_waiters, &fz_wait); | 1056 | __add_wait_queue_tail_exclusive(&gedf_env->fz_waiters, &fz_wait); |
1070 | // // add_wait_queue(&gedf_env->fz_waiters, &fz_wait); | 1057 | |
1071 | // // // __add_wait_queue_tail(&gedf_env->fz_waiters, &fz_wait); | 1058 | TS_LOCK_SUSPEND; |
1059 | |||
1060 | spin_unlock_irqrestore(&gedf_env->fz_waiters.lock, flags); | ||
1061 | |||
1062 | BUG_ON(!gedf_res->linked_on && !bheap_node_in_heap(t_res->heap_node)); | ||
1072 | 1063 | ||
1073 | // // // spin_unlock_irqrestore(&gedf_env->fz_waiters.lock, flags); | 1064 | schedule(); |
1074 | 1065 | ||
1075 | // schedule(); | 1066 | TS_LOCK_RESUME; |
1076 | 1067 | ||
1077 | // printk("%d awake!\n", t->pid); | 1068 | printk("%d awake!\n", t->pid); |
1078 | } else { | 1069 | } else { |
1079 | printk("%d is not in the FZ, budget remaining is %llu\n", | 1070 | printk("%d is not in the FZ, budget remaining is %llu\n", |
1080 | t->pid, remaining_component_budget); | 1071 | t->pid, remaining_component_budget); |
1072 | spin_unlock_irqrestore(&gedf_env->fz_waiters.lock, flags); | ||
1081 | } | 1073 | } |
1082 | |||
1083 | 1074 | ||
1084 | return 0; | 1075 | return 0; |
1085 | } | 1076 | } |