@@ -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