-
Notifications
You must be signed in to change notification settings - Fork 0
/
making_syscall.txt
134 lines (134 loc) · 3.2 KB
/
making_syscall.txt
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
diff -r p3/xv6/include/syscall.h p1/xv6/include/syscall.h
5,25c5,26
< #define SYS_fork 1
< #define SYS_exit 2
< #define SYS_wait 3
< #define SYS_pipe 4
< #define SYS_write 5
< #define SYS_read 6
< #define SYS_close 7
< #define SYS_kill 8
< #define SYS_exec 9
< #define SYS_open 10
< #define SYS_mknod 11
< #define SYS_unlink 12
< #define SYS_fstat 13
< #define SYS_link 14
< #define SYS_mkdir 15
< #define SYS_chdir 16
< #define SYS_dup 17
< #define SYS_getpid 18
< #define SYS_sbrk 19
< #define SYS_sleep 20
< #define SYS_uptime 21
---
> #define SYS_fork 1
> #define SYS_exit 2
> #define SYS_wait 3
> #define SYS_pipe 4
> #define SYS_write 5
> #define SYS_read 6
> #define SYS_close 7
> #define SYS_kill 8
> #define SYS_exec 9
> #define SYS_open 10
> #define SYS_mknod 11
> #define SYS_unlink 12
> #define SYS_fstat 13
> #define SYS_link 14
> #define SYS_mkdir 15
> #define SYS_chdir 16
> #define SYS_dup 17
> #define SYS_getpid 18
> #define SYS_sbrk 19
> #define SYS_sleep 20
> #define SYS_uptime 21
> #define SYS_getprocs 22
diff -r p3/xv6/kernel/defs.h p1/xv6/kernel/defs.h
99a100
> int getprocs(void);
diff -r p3/xv6/kernel/proc.c p1/xv6/kernel/proc.c
123a124,140
>
> // Count the currently running processes
> int
> getprocs(void)
> {
> struct proc *p;
> int count = 0;
>
> acquire(&ptable.lock);
> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
> if(p->state != UNUSED)
> count++;
> release(&ptable.lock);
>
> return count;
> }
>
diff -r p3/xv6/kernel/syscall.c p1/xv6/kernel/syscall.c
85,105c85,106
< [SYS_chdir] sys_chdir,
< [SYS_close] sys_close,
< [SYS_dup] sys_dup,
< [SYS_exec] sys_exec,
< [SYS_exit] sys_exit,
< [SYS_fork] sys_fork,
< [SYS_fstat] sys_fstat,
< [SYS_getpid] sys_getpid,
< [SYS_kill] sys_kill,
< [SYS_link] sys_link,
< [SYS_mkdir] sys_mkdir,
< [SYS_mknod] sys_mknod,
< [SYS_open] sys_open,
< [SYS_pipe] sys_pipe,
< [SYS_read] sys_read,
< [SYS_sbrk] sys_sbrk,
< [SYS_sleep] sys_sleep,
< [SYS_unlink] sys_unlink,
< [SYS_wait] sys_wait,
< [SYS_write] sys_write,
< [SYS_uptime] sys_uptime,
---
> [SYS_chdir] sys_chdir,
> [SYS_close] sys_close,
> [SYS_dup] sys_dup,
> [SYS_exec] sys_exec,
> [SYS_exit] sys_exit,
> [SYS_fork] sys_fork,
> [SYS_fstat] sys_fstat,
> [SYS_getpid] sys_getpid,
> [SYS_getprocs] sys_getprocs,
> [SYS_kill] sys_kill,
> [SYS_link] sys_link,
> [SYS_mkdir] sys_mkdir,
> [SYS_mknod] sys_mknod,
> [SYS_open] sys_open,
> [SYS_pipe] sys_pipe,
> [SYS_read] sys_read,
> [SYS_sbrk] sys_sbrk,
> [SYS_sleep] sys_sleep,
> [SYS_unlink] sys_unlink,
> [SYS_wait] sys_wait,
> [SYS_write] sys_write,
> [SYS_uptime] sys_uptime,
diff -r p3/xv6/kernel/sysfunc.h p1/xv6/kernel/sysfunc.h
12a13
> int sys_getprocs(void);
diff -r p3/xv6/kernel/sysproc.c p1/xv6/kernel/sysproc.c
44a45,50
> sys_getprocs(void)
> {
> return getprocs();
> }
>
> int
diff -r p3/xv6/user/makefile.mk p1/xv6/user/makefile.mk
6a7
> getprocs\
diff -r p3/xv6/user/user.h p1/xv6/user/user.h
24a25
> int getprocs(void);
diff -r p3/xv6/user/usys.S p1/xv6/user/usys.S
28a29
> SYSCALL(getprocs)