Repository navigation
scheduler: add pending_cnt for task to make pending scheduling possible #778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1271,7 +1271,8 @@ void pipeline_schedule_copy(struct pipeline *p, uint64_t start) | |
| * buffers prior to trigger start. */ | ||
| void pipeline_schedule_copy_idle(struct pipeline *p) | ||
| { | ||
| schedule_task_idle(&p->pipe_task, p->ipc_pipe.deadline); | ||
| // schedule_task_idle(&p->pipe_task, p->ipc_pipe.deadline); | ||
| schedule_task(&p->pipe_task, 0, p->ipc_pipe.deadline); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it should not be named pipeline_schedule_copy_idle()? |
||
|
|
||
| void pipeline_schedule_cancel(struct pipeline *p) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,17 +263,17 @@ static int _schedule_task(struct task *task, uint64_t start, uint64_t deadline) | |
|
|
||
| spin_lock_irq(&sch->lock, flags); | ||
|
|
||
| /* is task already pending ? - not enough MIPS to complete ? */ | ||
| if (task->state == TASK_STATE_PENDING) { | ||
| trace_schedule("_schedule_task(), task already pending"); | ||
| spin_unlock_irq(&sch->lock, flags); | ||
| return 0; | ||
| } | ||
|
|
||
| /* is task already queued ? - not enough MIPS to complete ? */ | ||
| if (task->state == TASK_STATE_QUEUED) { | ||
| trace_schedule("_schedule_task(), task already queued"); | ||
| spin_unlock_irq(&sch->lock, flags); | ||
| /* | ||
| * increase pending_cnt, will schedule it after this | ||
| * pending one is finished. | ||
| */ | ||
| if (task->state == TASK_STATE_PENDING || | ||
| task->state == TASK_STATE_QUEUED || | ||
| task->state == TASK_STATE_RUNNING || | ||
| task->state == TASK_STATE_PREEMPTED) { | ||
| trace_schedule("task 0x%xalready WIP, schedule it later...", | ||
| (uint32_t)(uint32_t *)task); | ||
| task->pending_cnt++; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spin_unlock_irq() |
||
| return 0; | ||
| } | ||
|
|
||
|
|
@@ -292,6 +292,9 @@ static int _schedule_task(struct task *task, uint64_t start, uint64_t deadline) | |
| /* calculate deadline - TODO: include MIPS */ | ||
| task->deadline = task->start + ticks_per_ms * deadline / 1000; | ||
|
|
||
| if (task->pending_cnt) | ||
| task->pending_cnt--; | ||
|
|
||
| /* add task to list */ | ||
| list_item_append(&task->list, &sch->list); | ||
| task->state = TASK_STATE_QUEUED; | ||
|
|
@@ -337,6 +340,8 @@ void schedule_task(struct task *task, uint64_t start, uint64_t deadline) | |
| void schedule_task_complete(struct task *task) | ||
| { | ||
| struct schedule_data *sch = *arch_schedule_get(); | ||
| uint64_t ticks_per_ms; | ||
| uint64_t deadline; | ||
| uint32_t flags; | ||
|
|
||
| tracev_schedule("schedule_task_complete()"); | ||
|
|
@@ -367,6 +372,13 @@ void schedule_task_complete(struct task *task) | |
|
|
||
| /* tell any waiter that task has completed */ | ||
| wait_completed(&task->complete); | ||
|
|
||
| /* schedule the same pending task */ | ||
| if (task->pending_cnt) { | ||
| ticks_per_ms = clock_ms_to_ticks(sch->clock, 1); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pending_cnt may be wrong now. |
||
| deadline = (task->deadline - task->start) * 1000 / ticks_per_ms; | ||
| schedule_task(task, 0, deadline); | ||
| } | ||
| } | ||
|
|
||
| /* Update task state to running */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove check state? Even in TASK_STATE_FREE, TASK_STATE_CANEL, TAKS_STATE_INIT and so on without our any cnt > 0?