diff options
author | Stephen Tang <sytang@pound.cs.unc.edu> | 2017-04-03 23:59:54 -0400 |
---|---|---|
committer | Stephen Tang <sytang@pound.cs.unc.edu> | 2017-04-03 23:59:54 -0400 |
commit | 12787b2fa6aa96ee501dd34a26c6d887f28872ff (patch) | |
tree | 39f5ac47407e2a2a83a8659a9aa65d6f23994d2b /litmus | |
parent | 09171c9b875a8e51b48b7c2eabc38401191a2245 (diff) | |
parent | d966612f2eac9d0f8d0ddae92b1c6914e82e603a (diff) |
Merge branch 'wip-modechange' of ssh://rtsrv.cs.unc.edu/home/litmus/litmus-rt into wip-modechange
Diffstat (limited to 'litmus')
-rw-r--r-- | litmus/sched_mc2.c | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/litmus/sched_mc2.c b/litmus/sched_mc2.c index ee04315c44a0..525af34f0875 100644 --- a/litmus/sched_mc2.c +++ b/litmus/sched_mc2.c | |||
@@ -117,7 +117,7 @@ bool cpu_0_spin_flag; | |||
117 | * A and B hyperperiod | 117 | * A and B hyperperiod |
118 | */ | 118 | */ |
119 | 119 | ||
120 | asmlinkage int sys_enact_mode(void) | 120 | asmlinkage long sys_enact_mode(void) |
121 | { | 121 | { |
122 | struct mc2_cpu_state *state = local_cpu_state(); | 122 | struct mc2_cpu_state *state = local_cpu_state(); |
123 | struct list_head *pos; | 123 | struct list_head *pos; |
@@ -128,25 +128,53 @@ asmlinkage int sys_enact_mode(void) | |||
128 | raw_spin_lock(&global_lock); | 128 | raw_spin_lock(&global_lock); |
129 | raw_spin_lock(&mode_lock); | 129 | raw_spin_lock(&mode_lock); |
130 | if (mode != requested_mode //MCR has entered | 130 | if (mode != requested_mode //MCR has entered |
131 | && !res_reported){ //and C is throttled | 131 | if( !res_reported){ //and C is throttled |
132 | mode = requested_mode; | 132 | mode = requested_mode; |
133 | _global_env = &_global_env_modes[mode]; | 133 | _global_env = &_global_env_modes[mode]; |
134 | //set res->reported for new global tasks | 134 | //set res->reported for new global tasks |
135 | list_for_each(pos, &_global_env->active_reservations){ | 135 | list_for_each(pos, &_global_env->active_reservations){ |
136 | res = list_entry(pos, struct reservation, list); | 136 | res = list_entry(pos, struct reservation, list); |
137 | 137 | res->reported = 0; | |
138 | res->reported = 0; | 138 | } |
139 | } | 139 | list_for_each(pos, &_global_env->depleted_reservations){ |
140 | list_for_each(pos, &_global_env->depleted_reservations){ | 140 | res = list_entry(pos, struct reservation, list); |
141 | res = list_entry(pos, struct reservation, list); | 141 | res->reported = 0; |
142 | res->reported = 0; | 142 | } |
143 | list_for_each(pos, &_global_env->inactive_reservations){ | ||
144 | res = list_entry(pos, struct reservation, list); | ||
145 | res->reported = 0; | ||
146 | res->env->change_state(res->env, res, RESERVATION_ACTIVE); | ||
147 | } | ||
148 | //gmp_update_time(_global_env, now); | ||
143 | } | 149 | } |
144 | list_for_each(pos, &_global_env->inactive_reservations){ | 150 | else{ |
145 | res = list_entry(pos, struct reservation, list); | 151 | list_for_each(pos, &_global_env->active_reservations){ |
146 | res->reported = 0; | 152 | res = list_entry(pos, struct reservation, list); |
147 | res->env->change_state(res->env, res, RESERVATION_ACTIVE); | 153 | if (tsk_rt(res->tsk)->completed){ |
154 | res->env->change_state(res->env, res, RESERVATION_INACTIVE); | ||
155 | res->reported = 1; | ||
156 | res_reported--; | ||
157 | } | ||
158 | } | ||
159 | list_for_each(pos, &_global_env->depleted_reservations){ | ||
160 | res = list_entry(pos, struct reservation, list); | ||
161 | if (tsk_rt(res->tsk)->completed){ | ||
162 | res->env->change_state(res->env, res, RESERVATION_INACTIVE); | ||
163 | res->reported = 1; | ||
164 | res_reported--; | ||
165 | } | ||
166 | |||
167 | } | ||
168 | list_for_each(pos, &_global_env->inactive_reservations){ | ||
169 | res = list_entry(pos, struct reservation, list); | ||
170 | if (tsk_rt(res->tsk)->completed){ | ||
171 | res->env->change_state(res->env, res, RESERVATION_INACTIVE); | ||
172 | res->reported = 1; | ||
173 | res_reported--; | ||
174 | } | ||
175 | } | ||
148 | } | 176 | } |
149 | //gmp_update_time(_global_env, now); | 177 | |
150 | } | 178 | } |
151 | raw_spin_unlock(&mode_lock); | 179 | raw_spin_unlock(&mode_lock); |
152 | raw_spin_unlock(&global_lock); | 180 | raw_spin_unlock(&global_lock); |
@@ -173,7 +201,7 @@ asmlinkage int sys_enact_mode(void) | |||
173 | * Called from non-real time program | 201 | * Called from non-real time program |
174 | * Protect by exclusive lock to prevent from occuring while mode change is enacted | 202 | * Protect by exclusive lock to prevent from occuring while mode change is enacted |
175 | */ | 203 | */ |
176 | asmlinkage int sys_request_mode(int new_mode){ | 204 | asmlinkage long sys_request_mode(int new_mode){ |
177 | raw_spin_lock(&mode_lock); | 205 | raw_spin_lock(&mode_lock); |
178 | if (mode != requested_mode){ | 206 | if (mode != requested_mode){ |
179 | raw_spin_unlock(&mode_lock); | 207 | raw_spin_unlock(&mode_lock); |
@@ -617,9 +645,11 @@ static long mc2_complete_job(void) | |||
617 | long err; | 645 | long err; |
618 | 646 | ||
619 | enum crit_level lv; | 647 | enum crit_level lv; |
620 | |||
621 | tsk_rt(current)->completed = 1; | ||
622 | 648 | ||
649 | raw_spin_lock(&mode_lock); | ||
650 | tsk_rt(current)->completed = 1; | ||
651 | raw_spin_unlock(&mode_lock); | ||
652 | |||
623 | lv = get_task_crit_level(current); | 653 | lv = get_task_crit_level(current); |
624 | 654 | ||
625 | /* If this the first job instance, we need to reset replenish | 655 | /* If this the first job instance, we need to reset replenish |
@@ -734,7 +764,9 @@ static long mc2_complete_job(void) | |||
734 | 764 | ||
735 | TRACE_CUR("mc2_complete_job returns at %llu\n", litmus_clock()); | 765 | TRACE_CUR("mc2_complete_job returns at %llu\n", litmus_clock()); |
736 | 766 | ||
767 | raw_spin_lock(&mode_lock); | ||
737 | tsk_rt(current)->completed = 0; | 768 | tsk_rt(current)->completed = 0; |
769 | raw_spin_unlock(&mode_lock); | ||
738 | return err; | 770 | return err; |
739 | } | 771 | } |
740 | 772 | ||