update controller code

This commit is contained in:
Rongsong Shen 2025-11-05 16:58:57 +08:00
parent 2836d196da
commit 41f56fa6ed
54 changed files with 9688 additions and 214 deletions

View file

@ -63,14 +63,14 @@ void vcpu_idle(vcpu_t* vcpu)
void run_task(vtask_t* task)
{
vtaskmgr_t *vtaskmgr;
vtaskmgr_t* vtaskmgr;
if (task->entry != NULL) {
(task->entry)(task);
}
endpoint_unblock_tasks(task->ctx.ep);
vtaskmgr = (vtaskmgr_t *)task->owner;
vtaskmgr = (vtaskmgr_t*)task->owner;
if (vtaskmgr != NULL) {
/* wake up dispatcher */
vtaskmgr_wakeup(vtaskmgr);
@ -209,14 +209,14 @@ static vcpu_t* pick_idle_vcpu(vtaskmgr_t* vtaskmgr)
TRACE("%s pick idle cpu #%d",
__func__, i);
return &(vtaskmgr->vcpus[i]);
}
static int vtask_eligible(data_item_t* data)
{
vtask_t* task = ITPTR_TO_VTASK(data);
int eligible = 0;
vtask_t* task = ITPTR_TO_VTASK(data);
int eligible = 0;
if (task->ctx.ep == NULL) {
WARN("no endpoint for task 0x%p", task);
@ -226,7 +226,7 @@ static int vtask_eligible(data_item_t* data)
eligible = !(endpoint_is_task_blocked(task->ctx.ep));
TRACE("%s vtask %p is %s",
__func__, task,
eligible?"eligible":"not eligible");
eligible ? "eligible" : "not eligible");
return eligible;
}
@ -283,8 +283,7 @@ static void* vdispatcher_entry(void* arg)
bind_vtask(task, vcpu);
vcpu = NULL;
task = NULL;
}
else {
} else {
vtaskmgr_wait(vtaskmgr);
}
}
@ -308,13 +307,15 @@ int vtaskmgr_start(vtaskmgr_t* vtaskmgr)
return 0;
}
void vtaskmgr_wait(vtaskmgr_t *vtaskmgr) {
void vtaskmgr_wait(vtaskmgr_t* vtaskmgr)
{
int dummy = 0;
cbuf_get(&(vtaskmgr->wtbuf), &dummy);
}
void vtaskmgr_wakeup(vtaskmgr_t *vtaskmgr) {
void vtaskmgr_wakeup(vtaskmgr_t* vtaskmgr)
{
int dummy = 0;
cbuf_tryput(&(vtaskmgr->wtbuf), &dummy);
@ -351,7 +352,7 @@ int vtask_enq(vtaskmgr_t* vtaskmgr,
ioctx_ref(&(task->ctx));
rc = dataq_enq(&(vtaskmgr->taskq),
&(task->ctx.link));
&(task->ctx.link));
if (rc >= 0) {
/* wake up task dispatcher */
task->owner = vtaskmgr;