code:nice - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki

Source

  • 设置 现行进程的优先级
  • 共传入一个参数 设为t
  • 对普通用户,t的有效范围为 0 ~ 20
  • 对超级用户,t的有效范围为 -128 ~ 20

3492

3493 nice()

3494 {

3495     register n;

3496

3497     n = u.u_ar0[R0];

3498     if(n > 20)

3499          n = 20;

  • 修正上限
3500     if(n < 0 && !suser())

3501          n = 0;

  • 对于 普通用户 ,修正下限
3502     u.u_procp->p_nice = n;
3503 }

3504 /* ------------------------- */

Ref

Param

(nice = 34.)
(priority in r0)
sys nice
⚠️ **GitHub.com Fallback** ⚠️