summaryrefslogtreecommitdiff
path: root/riscos/schedule.c
diff options
context:
space:
mode:
Diffstat (limited to 'riscos/schedule.c')
-rw-r--r--riscos/schedule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/riscos/schedule.c b/riscos/schedule.c
index 52e5e2660..c055c219f 100644
--- a/riscos/schedule.c
+++ b/riscos/schedule.c
@@ -118,15 +118,21 @@ void schedule_remove(void (*callback)(void *p), void *p)
void schedule_run(void)
{
struct sched_entry *entry;
+ void (*callback)(void *p);
+ void *p;
os_t now;
now = os_read_monotonic_time();
while (sched_queue.next && sched_queue.next->time <= now) {
entry = sched_queue.next;
- entry->callback(entry->p);
+ callback = entry->callback;
+ p = entry->p;
sched_queue.next = entry->next;
free(entry);
+ /* The callback may call schedule() or schedule_remove(), so
+ * leave the queue in a safe state. */
+ callback(p);
}
if (sched_queue.next) {