Skip to content

Commit af1f5ea

Browse files
committed
[TEST] schedule: twb: set COMPLETED state after task_complete()
1 parent c45f7e5 commit af1f5ea

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/schedule/zephyr_twb_schedule.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,20 @@ static void twb_thread_fn(void *p1, void *p2, void *p3)
183183
* if not, set the state returned by run procedure
184184
*/
185185
if (task->state == SOF_TASK_STATE_RUNNING) {
186-
task->state = state;
186+
if (pdata->cycles_granted) {
187+
k_thread_runtime_stats_get(pdata->thread_id, &rt_stats_thread);
188+
pdata->cycles_consumed += rt_stats_thread.execution_cycles - pdata->cycles_ref;
189+
pdata->cycles_ref = rt_stats_thread.execution_cycles;
190+
}
187191
switch (state) {
188192
case SOF_TASK_STATE_RESCHEDULE:
189193
/* mark to reschedule, schedule time is already calculated */
190194
task->state = SOF_TASK_STATE_QUEUED;
195+
break;
191196
case SOF_TASK_STATE_CANCEL:
197+
task->state = SOF_TASK_STATE_CANCEL;
198+
break;
192199
case SOF_TASK_STATE_COMPLETED:
193-
if (pdata->cycles_granted) {
194-
k_thread_runtime_stats_get(pdata->thread_id, &rt_stats_thread);
195-
pdata->cycles_consumed += rt_stats_thread.execution_cycles - pdata->cycles_ref;
196-
pdata->cycles_ref = rt_stats_thread.execution_cycles;
197-
}
198200
break;
199201

200202
default:
@@ -206,8 +208,10 @@ static void twb_thread_fn(void *p1, void *p2, void *p3)
206208
scheduler_twb_unlock(lock_key);
207209

208210
/* call task_complete out of lock and save the stats */
209-
if (task->state == SOF_TASK_STATE_COMPLETED)
211+
if (state == SOF_TASK_STATE_COMPLETED) {
210212
task_complete(task);
213+
task->state = SOF_TASK_STATE_COMPLETED;
214+
}
211215

212216
if (task->state != SOF_TASK_STATE_RUNNING)
213217
k_thread_suspend(pdata->thread_id);

0 commit comments

Comments
 (0)