-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetPriority.c
More file actions
30 lines (27 loc) · 736 Bytes
/
Copy pathsetPriority.c
File metadata and controls
30 lines (27 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fs.h"
int main(int argc, char *argv[])
{
if (argc != 3)
{
printf(1,"Usage: setPriority <new_priority> <pid>\n");
}
else
{
int new_priority = atoi(argv[1]);
int pid = atoi(argv[2]);
if (new_priority<0 || new_priority>100)
{
printf(1,"<new_priority> should be between 0 and 100\n");
exit();
}
int old_priority = set_priority(new_priority, pid);
if (old_priority<0)
printf(1,"PID not found\n");
else
printf(1,"Process %d priority changed: Old priority %d -> New priority %d\n", pid, old_priority, new_priority);
}
exit();
}