Skip to content

Commit

Permalink
Merge pull request #360 from xiulipan/schfix2
Browse files Browse the repository at this point in the history
Fix for scheduler bugs
lgirdwood authored Sep 18, 2018
2 parents 0875f0c + 380c067 commit 7dd4b1d
Showing 3 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/arch/xtensa/task.c
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ static void _irq_task(void *arg)
uint32_t flags;

spin_lock_irq(&irq_task->lock, flags);
interrupt_clear(irq_task->irq);
list_for_item_safe(clist, tlist, &irq_task->list) {

task = container_of(clist, struct task, irq_list);
@@ -130,7 +131,6 @@ static void _irq_task(void *arg)
spin_lock_irq(&irq_task->lock, flags);
}

interrupt_clear(irq_task->irq);

spin_unlock_irq(&irq_task->lock, flags);
}
2 changes: 1 addition & 1 deletion src/include/sof/schedule.h
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ struct sof;
#define TASK_PRI_MED 0
#define TASK_PRI_HIGH -20

#define TASK_PRI_IPC 1
#define TASK_PRI_IPC 6

/* maximun task time slice in microseconds */
#define SCHEDULE_TASK_MAX_TIME_SLICE 5000
56 changes: 28 additions & 28 deletions src/lib/schedule.c
Original file line number Diff line number Diff line change
@@ -103,13 +103,9 @@ static inline struct task *edf_get_next(uint64_t current,
uint64_t delta;
uint64_t deadline;
int reschedule = 0;
uint32_t flags;

spin_lock_irq(&sch->lock, flags);

/* any tasks in the scheduler ? */
if (list_is_empty(&sch->list)) {
spin_unlock_irq(&sch->lock, flags);
return NULL;
}

@@ -160,7 +156,6 @@ static inline struct task *edf_get_next(uint64_t current,
}
}

spin_unlock_irq(&sch->lock, flags);
return next_task;
}

@@ -187,35 +182,40 @@ static struct task *schedule_edf(void)

tracev_pipe("edf");

/* get the current time */
current = platform_timer_get(platform_timer);

/* get next task to be scheduled */
task = edf_get_next(current, NULL);

interrupt_clear(PLATFORM_SCHEDULE_IRQ);

/* any tasks ? */
if (task == NULL)
return NULL;
while (!list_is_empty(&sch->list)) {
spin_lock_irq(&sch->lock, flags);

/* can task be started now ? */
if (task->start > current) {
/* no, then schedule wake up */
future_task = task;
} else {
/* yes, run current task */
task->start = current;
/* get the current time */
current = platform_timer_get(platform_timer);

/* init task for running */
wait_init(&task->complete);
spin_lock_irq(&sch->lock, flags);
task->state = TASK_STATE_RUNNING;
list_item_del(&task->list);
/* get next task to be scheduled */
task = edf_get_next(current, NULL);
spin_unlock_irq(&sch->lock, flags);

/* now run task at correct run level */
arch_run_task(task);
/* any tasks ? */
if (!task)
return NULL;

/* can task be started now ? */
if (task->start <= current) {
/* yes, run current task */
task->start = current;

/* init task for running */
spin_lock_irq(&sch->lock, flags);
task->state = TASK_STATE_RUNNING;
list_item_del(&task->list);
spin_unlock_irq(&sch->lock, flags);

/* now run task at correct run level */
arch_run_task(task);
} else {
/* no, then schedule wake up */
future_task = task;
break;
}
}

/* tell caller about future task */

0 comments on commit 7dd4b1d

Please sign in to comment.