linux 中的 getpriority() 函数

inq*_*ive 1 linux-kernel

我可以知道在 linux 中使用 getpriority() 调用的确切用法吗..即使在通过网络搜索之后,我也无法完全理解它..有人可以用一个例子来解释它..提前 :)

bma*_*ies 5

   The  scheduling  priority  of  the  process, process group, or user, as
   indicated by which and who is obtained with the  getpriority  call ...
Run Code Online (Sandbox Code Playgroud)

所以,它返回一个优先级。它需要两个参数。

第一个 arg 告诉它如何解释第二个 arg。

   which is ... one  of  PRIO_PROCESS,
   PRIO_PGRP, or PRIO_USER, 
Run Code Online (Sandbox Code Playgroud)

所以,如果which是PRIO_PROCESS,那么'who'就是进程ID,如果是PRIO_PGRP,就是进程组id,如果是PRIO_USER,就是用户ID。零表示呼叫者。

在后两种情况下,结果是选择一组进程,因此它返回所有选定进程的最低优先级编号。