-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sched2.c
More file actions
34 lines (28 loc) · 741 Bytes
/
test_sched2.c
File metadata and controls
34 lines (28 loc) · 741 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
31
32
33
34
#include "types.h"
#include "stat.h"
#include "user.h"
int main(int argc, char** argv) {
int pid;
int mypid;
// Change the priority of init process.
setnice(1, 10);
// Change the priority of current processes.
// setnice(getpid(), 2);
setnice(getpid(), 9); // <--- 부모를 9로 설정
// Create a child process
pid = fork();
if(pid == 0) {
// Child
printf(1, "#### State 2 ####\n");
} else {
// Parent
printf(1, "#### State 1 ####\n");
// Change the priority of parent process
setnice(pid, 10);
wait();
printf(1, "#### State 3 ####\n");
}
mypid = getpid();
printf(1, "PID %d is finished\n", mypid);
exit();
}