static seg_t validate_address(seg_t base) { register struct task_struct *t; for_each_task(t) { if (t->mm.cseg == base && t->mm.flags & CS_SWAP) { do_swapper_run(t); return t->mm.cseg; } if (t->mm.dseg == base && t->mm.flags & DS_SWAP) { do_swapper_run(t); return t->mm.dseg; } } return base; }
void schedule(void) { register __ptask prev; register __ptask next; struct timer_list timer; jiff_t timeout = 0UL; prev = current; if (prev->t_kstackm != KSTACK_MAGIC) panic("Process %d exceeded kernel stack limit! magic %x\n", prev->pid, prev->t_kstackm); if (intr_count > 0) { /* Taking a timer IRQ during another IRQ or while in kernel space is * quite legal. We just dont switch then */ printk("Aiee: scheduling in interrupt %d - %d\n", intr_count, prev->pid); goto no_sched; } /* We have to let a task exit! */ if (prev->state == TASK_EXITING) goto no_sched; clr_irq(); if (prev->state == TASK_INTERRUPTIBLE) { if (prev->signal || (prev->timeout && (prev->timeout <= jiffies))) { prev->timeout = 0UL; prev->state = TASK_RUNNING; } else { timeout = prev->timeout; } } /* Choose a task to run next */ next = prev->next_run; if (prev->state != TASK_RUNNING) del_from_runqueue(prev); if (next == &init_task) next = next->next_run; set_irq(); if (next != prev) { if (timeout) { init_timer(&timer); timer.tl_expires = timeout; timer.tl_data = (int) prev; timer.tl_function = process_timeout; add_timer(&timer); } #ifdef CONFIG_SWAP if (do_swapper_run(next) == -1){ printk("Can't become runnable %d\n", next->pid); panic(""); } #endif previous = prev; current = next; tswitch(); /* Won't return for a new task */ if (timeout) { del_timer(&timer); } } no_sched: ; }