
GETPRIORITY(2)             UNIX Programmer's Manual             GETPRIORITY(2)

NNAAMMEE
     ggeettpprriioorriittyy, sseettpprriioorriittyy - get/set program scheduling priority

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<ssyyss//ttiimmee..hh>>
     ##iinncclluuddee <<ssyyss//rreessoouurrccee..hh>>

     _i_n_t
     ggeettpprriioorriittyy(_i_n_t _w_h_i_c_h, _i_n_t _w_h_o)

     _i_n_t
     sseettpprriioorriittyy(_i_n_t _w_h_i_c_h, _i_n_t _w_h_o, _i_n_t _p_r_i_o)

DDEESSCCRRIIPPTTIIOONN
     The scheduling priority of the process, process group, or user, as indi-
     cated by _w_h_i_c_h and _w_h_o is obtained with the ggeettpprriioorriittyy() call and set
     with the sseettpprriioorriittyy() call.  _W_h_i_c_h is one of PRIO_PROCESS, PRIO_PGRP, or
     PRIO_USER, and _w_h_o is interpreted relative to _w_h_i_c_h (a process identifier
     for PRIO_PROCESS, process group identifier for PRIO_PGRP, and a user ID
     for PRIO_USER). A zero value of _w_h_o denotes the current process, process
     group, or user.  _P_r_i_o is a value in the range -20 to 20.  The default
     priority is 0; lower priorities cause more favorable scheduling.

     The ggeettpprriioorriittyy() call returns the highest priority (lowest numerical
     value) enjoyed by any of the specified processes.  The sseettpprriioorriittyy() call
     sets the priorities of all of the specified processes to the specified
     value.  Only the super-user may lower priorities.

RREETTUURRNN VVAALLUUEESS
     Since ggeettpprriioorriittyy() can legitimately return the value -1, it is necessary
     to clear the external variable _e_r_r_n_o prior to the call, then check it af-
     terward to determine if a -1 is an error or a legitimate value.  The
     sseettpprriioorriittyy() call returns 0 if there is no error, or -1 if there is.

EERRRROORRSS
     GGeettpprriioorriittyy() and sseettpprriioorriittyy() will fail if:

     [ESRCH]       No process was located using the _w_h_i_c_h and _w_h_o values spec-
                   ified.

     [EINVAL]      _W_h_i_c_h was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.

     In addition to the errors indicated above, sseettpprriioorriittyy() will fail if:

     [EPERM]       A process was located, but neither its effective nor real
                   user ID matched the effective user ID of the caller.

     [EACCES]      A non super-user attempted to lower a process priority.

SSEEEE AALLSSOO
     nice(1),  fork(2),  renice(8)

HHIISSTTOORRYY
     The ggeettpprriioorriittyy function call appeared in 4.2BSD.

4th Berkeley Distribution       March 10, 1991                               1







