mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-13 11:33:58 +00:00
scheduler: make scheduling based on struct sched_object
use struct sched_object as the main interface of scheduling, then make scheduler as an independent module to vcpu: - add struct sched_object as one field in struct vcpu - define sched_object.thread for switch_to thread - define sched_object.prepare_switch_out/in for prepare_switch before switch_to - move context_switch_out/context_switch_in into vcpu.c as vcpu.sched_obj.prepare_switch_out/in - make default_idle as global idle.thread for idle_thread - make vcpu_thread as vcpu.sched_obj.thread for each vcpu thread - simplify switch_to based on sched_object Tracked-On: #1842 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <edide.dong@intel.com>
This commit is contained in:
@@ -17,8 +17,9 @@ static void run_vcpu_pre_work(struct acrn_vcpu *vcpu)
|
||||
}
|
||||
}
|
||||
|
||||
void vcpu_thread(struct acrn_vcpu *vcpu)
|
||||
void vcpu_thread(struct sched_object *obj)
|
||||
{
|
||||
struct acrn_vcpu *vcpu = list_entry(obj, struct acrn_vcpu, sched_obj);
|
||||
uint32_t basic_exit_reason = 0U;
|
||||
int32_t ret = 0;
|
||||
|
||||
@@ -88,3 +89,21 @@ void vcpu_thread(struct acrn_vcpu *vcpu)
|
||||
profiling_post_vmexit_handler(vcpu);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void default_idle(__unused struct sched_object *obj)
|
||||
{
|
||||
uint16_t pcpu_id = get_cpu_id();
|
||||
|
||||
while (1) {
|
||||
if (need_reschedule(pcpu_id) != 0) {
|
||||
schedule();
|
||||
} else if (need_offline(pcpu_id) != 0) {
|
||||
cpu_dead();
|
||||
} else {
|
||||
CPU_IRQ_ENABLE();
|
||||
handle_complete_ioreq(pcpu_id);
|
||||
cpu_do_idle();
|
||||
CPU_IRQ_DISABLE();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user