xref: /minix3/lib/libc/sys/getpriority.2 (revision f14fb602092e015ff630df58e17c2a9cd57d29b3)
1*f14fb602SLionel Sambuc.\"	$NetBSD: getpriority.2,v 1.20 2012/04/13 16:32:15 wiz Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 1980, 1991, 1993
42fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
152fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
162fe8fb19SBen Gras.\"    without specific prior written permission.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
192fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
222fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
232fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
242fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
252fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
262fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
272fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
282fe8fb19SBen Gras.\" SUCH DAMAGE.
292fe8fb19SBen Gras.\"
302fe8fb19SBen Gras.\"     @(#)getpriority.2	8.1 (Berkeley) 6/4/93
312fe8fb19SBen Gras.\"
32*f14fb602SLionel Sambuc.Dd April 13, 2012
332fe8fb19SBen Gras.Dt GETPRIORITY 2
342fe8fb19SBen Gras.Os
352fe8fb19SBen Gras.Sh NAME
362fe8fb19SBen Gras.Nm getpriority ,
372fe8fb19SBen Gras.Nm setpriority
382fe8fb19SBen Gras.Nd get/set program scheduling priority
392fe8fb19SBen Gras.Sh LIBRARY
402fe8fb19SBen Gras.Lb libc
412fe8fb19SBen Gras.Sh SYNOPSIS
422fe8fb19SBen Gras.In sys/resource.h
432fe8fb19SBen Gras.Ft int
442fe8fb19SBen Gras.Fn getpriority "int which" "id_t who"
452fe8fb19SBen Gras.Ft int
462fe8fb19SBen Gras.Fn setpriority "int which" "id_t who" "int prio"
472fe8fb19SBen Gras.Sh DESCRIPTION
482fe8fb19SBen GrasThe scheduling
492fe8fb19SBen Graspriority of the process, process group, or user, as indicated by
502fe8fb19SBen Gras.Fa which
512fe8fb19SBen Grasand
522fe8fb19SBen Gras.Fa who
532fe8fb19SBen Grasis obtained with the
542fe8fb19SBen Gras.Fn getpriority
552fe8fb19SBen Grascall and set with the
562fe8fb19SBen Gras.Fn setpriority
572fe8fb19SBen Grascall.
58*f14fb602SLionel Sambuc.Pp
59*f14fb602SLionel SambucThe priority is maintained in a per-process basis and
60*f14fb602SLionel Sambucaffects scheduling of LWPs which belong to the process and use the
61*f14fb602SLionel Sambuc.Dv SCHED_OTHER
62*f14fb602SLionel Sambucscheduling class.
63*f14fb602SLionel Sambuc.Pp
642fe8fb19SBen Gras.Fa which
652fe8fb19SBen Grasis one of
662fe8fb19SBen Gras.Dv PRIO_PROCESS ,
672fe8fb19SBen Gras.Dv PRIO_PGRP ,
682fe8fb19SBen Grasor
692fe8fb19SBen Gras.Dv PRIO_USER ,
702fe8fb19SBen Grasand
712fe8fb19SBen Gras.Fa who
722fe8fb19SBen Grasis interpreted relative to
732fe8fb19SBen Gras.Fa which
742fe8fb19SBen Gras(a process identifier for
752fe8fb19SBen Gras.Dv PRIO_PROCESS ,
762fe8fb19SBen Grasprocess group
772fe8fb19SBen Grasidentifier for
782fe8fb19SBen Gras.Dv PRIO_PGRP ,
792fe8fb19SBen Grasand a user ID for
802fe8fb19SBen Gras.Dv PRIO_USER ) .
812fe8fb19SBen GrasA zero value of
822fe8fb19SBen Gras.Fa who
832fe8fb19SBen Grasdenotes the current process, process group, or user.
842fe8fb19SBen Gras.Fa prio
852fe8fb19SBen Grasis a value in the range -20 to 20.
862fe8fb19SBen GrasThe default priority is 0;
87*f14fb602SLionel Sambucnumerically lower priority values cause more favorable scheduling.
882fe8fb19SBen GrasA value of 19 or 20
892fe8fb19SBen Graswill schedule a process only when nothing at priority \*(Le 0 is runnable.
902fe8fb19SBen Gras.Pp
912fe8fb19SBen GrasThe
922fe8fb19SBen Gras.Fn getpriority
932fe8fb19SBen Grascall returns the highest priority (lowest numerical value)
942fe8fb19SBen Grasenjoyed by any of the specified processes.
952fe8fb19SBen GrasThe
962fe8fb19SBen Gras.Fn setpriority
972fe8fb19SBen Grascall sets the priorities of all of the specified processes
982fe8fb19SBen Grasto the specified value.
99*f14fb602SLionel SambucOnly the super-user may lower priority values.
1002fe8fb19SBen Gras.Sh RETURN VALUES
1012fe8fb19SBen GrasSince
1022fe8fb19SBen Gras.Fn getpriority
1032fe8fb19SBen Grascan legitimately return the value \-1, it is necessary
1042fe8fb19SBen Grasto clear the external variable
1052fe8fb19SBen Gras.Va errno
1062fe8fb19SBen Grasprior to the
1072fe8fb19SBen Grascall, then check it afterward to determine
1082fe8fb19SBen Grasif a \-1 is an error or a legitimate value.
1092fe8fb19SBen GrasThe
1102fe8fb19SBen Gras.Fn setpriority
1112fe8fb19SBen Grascall returns 0 if there is no error, or
1122fe8fb19SBen Gras\-1 if there is.
1132fe8fb19SBen Gras.Sh ERRORS
1142fe8fb19SBen Gras.Fn getpriority
1152fe8fb19SBen Grasand
1162fe8fb19SBen Gras.Fn setpriority
1172fe8fb19SBen Graswill fail if:
1182fe8fb19SBen Gras.Bl -tag -width Er
1192fe8fb19SBen Gras.It Bq Er EINVAL
1202fe8fb19SBen Gras.Fa which
1212fe8fb19SBen Graswas not one of
1222fe8fb19SBen Gras.Dv PRIO_PROCESS ,
1232fe8fb19SBen Gras.Dv PRIO_PGRP ,
1242fe8fb19SBen Grasor
1252fe8fb19SBen Gras.Dv PRIO_USER .
126*f14fb602SLionel Sambuc.It Bq Er ESRCH
127*f14fb602SLionel SambucNo process was located using the
128*f14fb602SLionel Sambuc.Fa which
129*f14fb602SLionel Sambucand
130*f14fb602SLionel Sambuc.Fa who
131*f14fb602SLionel Sambucvalues specified.
1322fe8fb19SBen Gras.El
1332fe8fb19SBen Gras.Pp
1342fe8fb19SBen GrasIn addition to the errors indicated above,
1352fe8fb19SBen Gras.Fn setpriority
1362fe8fb19SBen Graswill fail if:
1372fe8fb19SBen Gras.Bl -tag -width Er
138*f14fb602SLionel Sambuc.It Bq Er EACCES
139*f14fb602SLionel SambucA non super-user attempted to lower a process priority value.
1402fe8fb19SBen Gras.It Bq Er EPERM
1412fe8fb19SBen GrasA process was located, but neither its effective nor real user
1422fe8fb19SBen GrasID matched the effective user ID of the caller.
1432fe8fb19SBen Gras.El
1442fe8fb19SBen Gras.Sh SEE ALSO
1452fe8fb19SBen Gras.Xr nice 1 ,
1462fe8fb19SBen Gras.Xr fork 2 ,
147*f14fb602SLionel Sambuc.Xr sched 3 ,
1482fe8fb19SBen Gras.Xr renice 8
1492fe8fb19SBen Gras.Sh HISTORY
1502fe8fb19SBen GrasThe
1512fe8fb19SBen Gras.Fn getpriority
1522fe8fb19SBen Grasfunction call appeared in
1532fe8fb19SBen Gras.Bx 4.2 .
154