#include struct task_struct * kvm_nextproc() { struct task_struct *task, *taskp; static unsigned long _task; static int n = NR_TASKS; if (_task == 0) _task = k_addr("_task") + 4; task = (struct task_struct *) xmalloc(sizeof(struct task_struct)); repeat: if (--n == 0) return(NULL); kmemread(&taskp, _task, 4); _task += 4; if (taskp == 0) goto repeat; kmemread(task, taskp, sizeof(struct task_struct)); /* check if valid, proc may have exited */ if ((unsigned) task->state > 4 || task->pid <= 0) goto repeat; return(task); } proc_compare(p1, p2) struct task_struct *p1, *p2; { if (p1 == NULL) return 1; return(p1->counter > p2->counter); } #define FSHIFT 11 #define FSCALE (1<