hv: sched: remove do_switch

Clean up do_swtich and do switch related things in schedule().

Tracked-On: #3813
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Shuo A Liu 2019-06-17 17:50:56 +08:00 committed by wenlingz
parent f04c491259
commit 15c6a3e31f
1 changed files with 11 additions and 19 deletions

View File

@ -145,20 +145,6 @@ bool need_reschedule(uint16_t pcpu_id)
return bitmap_test(NEED_RESCHEDULE, &ctl->flags);
}
static void do_switch(struct thread_object *prev, struct thread_object *next)
{
if ((prev != NULL) && (prev->switch_out != NULL)) {
prev->switch_out(prev);
}
/* update current object */
get_cpu_var(sched_ctl).curr_obj = next;
if ((next != NULL) && (next->switch_in != NULL)) {
next->switch_in(next);
}
}
void schedule(void)
{
uint16_t pcpu_id = get_pcpu_id();
@ -177,12 +163,18 @@ void schedule(void)
set_thread_status(prev, THREAD_STS_RUNNABLE);
}
set_thread_status(next, THREAD_STS_RUNNING);
ctl->curr_obj = next;
release_schedule_lock(pcpu_id);
if (prev == next) {
release_schedule_lock(pcpu_id);
} else {
do_switch(prev, next);
release_schedule_lock(pcpu_id);
/* If we picked different sched object, switch context */
if (prev != next) {
if ((prev != NULL) && (prev->switch_out != NULL)) {
prev->switch_out(prev);
}
if ((next != NULL) && (next->switch_in != NULL)) {
next->switch_in(next);
}
arch_switch_to(&prev->host_sp, &next->host_sp);
}