code:setrun - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
- 设置进程为就绪态
- 如有需要的话将进程调入内存
- 传入一个参数p
- p指向一个进程的proc结构
2129
2130 /*
2131 * Set the process running;
2132 * arrange for it to be swapped in if necessary.
2133 */
2134 setrun(p)
2135 {
2136 register struct proc *rp;
2137
2138 rp = p;
2139 rp->p_wchan = 0;
2140 rp->p_stat = SRUN;
2141 if(rp->p_pri < curpri)
- 将睡眠原因置为0
- 将进程状态置为SRUN(就绪状态)
2142 runrun++;
2143 if(runout != 0 && (rp->p_flag&SLOAD) == 0) {
- 若进程优先级比当前进程要高,则置runrun标志,以等待进程调度
- 参看 进程调度#runrun
2144 runout = 0;
2145 wakeup(&runout);
2146 }
2147 }
2148 /* ------------------------- */
2149