1 /*
2 priority.c
3 */
4
5 #include <sys/cdefs.h>
6 #include "namespace.h"
7 #include <errno.h>
8 #include <sys/types.h>
9 #include <sys/resource.h>
10 #include <lib.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <stddef.h>
14
15
getpriority(int which,id_t who)16 int getpriority(int which, id_t who)
17 {
18 int v;
19 message m;
20
21 memset(&m, 0, sizeof(m));
22 m.m_lc_pm_priority.which = which;
23 m.m_lc_pm_priority.who = who;
24
25 /* GETPRIORITY returns negative for error.
26 * Otherwise, it returns the priority plus the minimum
27 * priority, to distiginuish from error. We have to
28 * correct for this. (The user program has to check errno
29 * to see if something really went wrong.)
30 */
31
32 if((v = _syscall(PM_PROC_NR, PM_GETPRIORITY, &m)) < 0) {
33 return v;
34 }
35
36 return v + PRIO_MIN;
37 }
38
setpriority(int which,id_t who,int prio)39 int setpriority(int which, id_t who, int prio)
40 {
41 message m;
42
43 memset(&m, 0, sizeof(m));
44 m.m_lc_pm_priority.which = which;
45 m.m_lc_pm_priority.who = who;
46 m.m_lc_pm_priority.prio = prio;
47
48 return _syscall(PM_PROC_NR, PM_SETPRIORITY, &m);
49 }
50
51