mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 09:47:44 +00:00
hv: sched: decouple idle stuff from schedule module
Let init thread end with run_idle_thread(), then idle thread take over and start to do scheduling. Change enter_guest_mode() to init_guest_mode() as run_idle_thread() is removed out of it. Also add run_thread() in schedule module to run thread_object's thread loop directly. rename: switch_to_idle -> run_idle_thread Tracked-On: #3813 Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
committed by
ACRN System Integration
parent
27163df9b1
commit
0f70a5ca3a
@@ -11,6 +11,7 @@
|
||||
#include <irq.h>
|
||||
#include <schedule.h>
|
||||
#include <profiling.h>
|
||||
#include <sprintf.h>
|
||||
#include <trace.h>
|
||||
#include <logmsg.h>
|
||||
|
||||
@@ -90,3 +91,22 @@ void default_idle(__unused struct thread_object *obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void run_idle_thread(void)
|
||||
{
|
||||
uint16_t pcpu_id = get_pcpu_id();
|
||||
struct thread_object *idle = &per_cpu(idle, pcpu_id);
|
||||
char idle_name[16];
|
||||
|
||||
snprintf(idle_name, 16U, "idle%hu", pcpu_id);
|
||||
(void)strncpy_s(idle->name, 16U, idle_name, 16U);
|
||||
idle->pcpu_id = pcpu_id;
|
||||
idle->thread_entry = default_idle;
|
||||
idle->switch_out = NULL;
|
||||
idle->switch_in = NULL;
|
||||
|
||||
run_thread(idle);
|
||||
|
||||
/* Control should not come here */
|
||||
cpu_dead();
|
||||
}
|
||||
|
@@ -194,29 +194,14 @@ void wake_thread(struct thread_object *obj)
|
||||
release_schedule_lock(pcpu_id);
|
||||
}
|
||||
|
||||
void run_sched_thread(struct thread_object *obj)
|
||||
void run_thread(struct thread_object *obj)
|
||||
{
|
||||
get_schedule_lock(obj->pcpu_id);
|
||||
get_cpu_var(sched_ctl).curr_obj = obj;
|
||||
set_thread_status(obj, THREAD_STS_RUNNING);
|
||||
release_schedule_lock(obj->pcpu_id);
|
||||
|
||||
if (obj->thread_entry != NULL) {
|
||||
obj->thread_entry(obj);
|
||||
}
|
||||
|
||||
ASSERT(false, "Shouldn't go here, invalid thread entry!");
|
||||
}
|
||||
|
||||
void switch_to_idle(thread_entry_t idle_thread)
|
||||
{
|
||||
uint16_t pcpu_id = get_pcpu_id();
|
||||
struct thread_object *idle = &per_cpu(idle, pcpu_id);
|
||||
char idle_name[16];
|
||||
|
||||
snprintf(idle_name, 16U, "idle%hu", pcpu_id);
|
||||
(void)strncpy_s(idle->name, 16U, idle_name, 16U);
|
||||
idle->pcpu_id = pcpu_id;
|
||||
idle->thread_entry = idle_thread;
|
||||
idle->switch_out = NULL;
|
||||
idle->switch_in = NULL;
|
||||
get_cpu_var(sched_ctl).curr_obj = idle;
|
||||
set_thread_status(idle, THREAD_STS_RUNNING);
|
||||
|
||||
run_sched_thread(idle);
|
||||
}
|
||||
|
Reference in New Issue
Block a user