Skip to content

Commit 7dd4b1d

Browse files
authored
Merge pull request #360 from xiulipan/schfix2
Fix for scheduler bugs
2 parents 0875f0c + 380c067 commit 7dd4b1d

3 files changed

Lines changed: 30 additions & 30 deletions

File tree

src/arch/xtensa/task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ static void _irq_task(void *arg)
116116
uint32_t flags;
117117

118118
spin_lock_irq(&irq_task->lock, flags);
119+
interrupt_clear(irq_task->irq);
119120
list_for_item_safe(clist, tlist, &irq_task->list) {
120121

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

133-
interrupt_clear(irq_task->irq);
134134

135135
spin_unlock_irq(&irq_task->lock, flags);
136136
}

src/include/sof/schedule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct sof;
5656
#define TASK_PRI_MED 0
5757
#define TASK_PRI_HIGH -20
5858

59-
#define TASK_PRI_IPC 1
59+
#define TASK_PRI_IPC 6
6060

6161
/* maximun task time slice in microseconds */
6262
#define SCHEDULE_TASK_MAX_TIME_SLICE 5000

src/lib/schedule.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,9 @@ static inline struct task *edf_get_next(uint64_t current,
103103
uint64_t delta;
104104
uint64_t deadline;
105105
int reschedule = 0;
106-
uint32_t flags;
107106

108-
spin_lock_irq(&sch->lock, flags);
109-
110107
/* any tasks in the scheduler ? */
111108
if (list_is_empty(&sch->list)) {
112-
spin_unlock_irq(&sch->lock, flags);
113109
return NULL;
114110
}
115111

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

163-
spin_unlock_irq(&sch->lock, flags);
164159
return next_task;
165160
}
166161

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

188183
tracev_pipe("edf");
189184

190-
/* get the current time */
191-
current = platform_timer_get(platform_timer);
192-
193-
/* get next task to be scheduled */
194-
task = edf_get_next(current, NULL);
195-
196185
interrupt_clear(PLATFORM_SCHEDULE_IRQ);
197186

198-
/* any tasks ? */
199-
if (task == NULL)
200-
return NULL;
187+
while (!list_is_empty(&sch->list)) {
188+
spin_lock_irq(&sch->lock, flags);
201189

202-
/* can task be started now ? */
203-
if (task->start > current) {
204-
/* no, then schedule wake up */
205-
future_task = task;
206-
} else {
207-
/* yes, run current task */
208-
task->start = current;
190+
/* get the current time */
191+
current = platform_timer_get(platform_timer);
209192

210-
/* init task for running */
211-
wait_init(&task->complete);
212-
spin_lock_irq(&sch->lock, flags);
213-
task->state = TASK_STATE_RUNNING;
214-
list_item_del(&task->list);
193+
/* get next task to be scheduled */
194+
task = edf_get_next(current, NULL);
215195
spin_unlock_irq(&sch->lock, flags);
216196

217-
/* now run task at correct run level */
218-
arch_run_task(task);
197+
/* any tasks ? */
198+
if (!task)
199+
return NULL;
200+
201+
/* can task be started now ? */
202+
if (task->start <= current) {
203+
/* yes, run current task */
204+
task->start = current;
205+
206+
/* init task for running */
207+
spin_lock_irq(&sch->lock, flags);
208+
task->state = TASK_STATE_RUNNING;
209+
list_item_del(&task->list);
210+
spin_unlock_irq(&sch->lock, flags);
211+
212+
/* now run task at correct run level */
213+
arch_run_task(task);
214+
} else {
215+
/* no, then schedule wake up */
216+
future_task = task;
217+
break;
218+
}
219219
}
220220

221221
/* tell caller about future task */

0 commit comments

Comments
 (0)