hv: sched: add sleep/wake for thread object

sleep one thread_object means to prevent it from being scheduled.
wake one thread_object is an opposite operation of sleep.
This patch also add notify_mode in thread_object to indicate how to
deliver the request.

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-14 13:10:05 +08:00
committed by ACRN System Integration
parent 9b8c6e6a90
commit 27163df9b1
3 changed files with 45 additions and 26 deletions

View File

@@ -164,6 +164,36 @@ void schedule(void)
}
}
void sleep_thread(struct thread_object *obj)
{
uint16_t pcpu_id = obj->pcpu_id;
get_schedule_lock(pcpu_id);
remove_thread_obj(obj, pcpu_id);
if (is_running(obj)) {
if (obj->notify_mode == SCHED_NOTIFY_INIT) {
make_reschedule_request(pcpu_id, DEL_MODE_INIT);
} else {
make_reschedule_request(pcpu_id, DEL_MODE_IPI);
}
}
set_thread_status(obj, THREAD_STS_BLOCKED);
release_schedule_lock(pcpu_id);
}
void wake_thread(struct thread_object *obj)
{
uint16_t pcpu_id = obj->pcpu_id;
get_schedule_lock(pcpu_id);
if (is_blocked(obj)) {
insert_thread_obj(obj, pcpu_id);
set_thread_status(obj, THREAD_STS_RUNNABLE);
make_reschedule_request(pcpu_id, DEL_MODE_IPI);
}
release_schedule_lock(pcpu_id);
}
void run_sched_thread(struct thread_object *obj)
{
if (obj->thread_entry != NULL) {