阅读背景:

哈工大操作系统实验3

来源:互联网 
void schedule(void) { int i,next,c; struct task_struct ** p; /* check alarm, wake up any interruptible tasks that have got a signal */ for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) if (*p) { if ((*p)->alarm && (*p)->alarm < jiffies) { (*p)->signal |= (1<<(SIGALRM-1)); (*p)->alarm = 0; } if (((*p)->signal & ~(_BLOCKABLE & (*p)->blocked)) && (*p)->state==TASK_INTERRUPTIBLE) { (*p)->state=TASK_RUNNING; /*可中断睡眠 => 就绪*/ fprintk(3,"%d\tJ\t%d\n",(*p)->pid,jiffies); } } /* this is the scheduler proper: */ while (1) { c = -1; next = 0; i = NR_TASKS; p = &task[NR_TASKS]; while (--i) { if (!*--p) continue; if ((*p)->state == TASK_RUNNING && (*p)->counter > c) c = (*p)->counter, next = i; } if (c) break; for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) if (*p) (*p)->counter = ((*p)->counter >> 1) + (*p)->priority; } /*编号为next的进程 运行*/ if(current->pid != task[next] ->pid) { /*时间片到时程序 => 就绪*/ if(current->state == TASK_RUNNING) fprintk(3,"%d\tJ\t%d\n",current->pid,jiffies); fprintk(3,"%d\tR\t%d\n",task[next]->pid,jiffies); } switch_to(next); } sleep_on() void schedule(void) { int i,next,c; struct task_s



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: