repo.or.cz
/
xv6-db.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
added base src
[xv6-db.git]
/
sysproc.c
blob
efaa372d846860abf32d56462c8b4f67f6f8e385
1
#include
"types.h"
2
#include
"x86.h"
3
#include
"defs.h"
4
#include
"param.h"
5
#include
"mmu.h"
6
#include
"proc.h"
7
8
int
9
sys_fork
(
void
)
10
{
11
return
fork
();
12
}
13
14
int
15
sys_exit
(
void
)
16
{
17
exit
();
18
return
0
;
// not reached
19
}
20
21
int
22
sys_wait
(
void
)
23
{
24
return
wait
();
25
}
26
27
int
28
sys_kill
(
void
)
29
{
30
int
pid
;
31
32
if
(
argint
(
0
, &
pid
) <
0
)
33
return
-
1
;
34
return
kill
(
pid
);
35
}
36
37
int
38
sys_getpid
(
void
)
39
{
40
return
proc
->
pid
;
41
}
42
43
int
44
sys_sbrk
(
void
)
45
{
46
int
addr
;
47
int
n
;
48
49
if
(
argint
(
0
, &
n
) <
0
)
50
return
-
1
;
51
addr
=
proc
->
sz
;
52
if
(
growproc
(
n
) <
0
)
53
return
-
1
;
54
return
addr
;
55
}
56
57
int
58
sys_sleep
(
void
)
59
{
60
int
n
;
61
uint ticks0
;
62
63
if
(
argint
(
0
, &
n
) <
0
)
64
return
-
1
;
65
acquire
(&
tickslock
);
66
ticks0
=
ticks
;
67
while
(
ticks
-
ticks0
<
n
){
68
if
(
proc
->
killed
){
69
release
(&
tickslock
);
70
return
-
1
;
71
}
72
sleep
(&
ticks
, &
tickslock
);
73
}
74
release
(&
tickslock
);
75
return
0
;
76
}
77
78
// return how many clock tick interrupts have occurred
79
// since boot.
80
int
81
sys_uptime
(
void
)
82
{
83
uint xticks
;
84
85
acquire
(&
tickslock
);
86
xticks
=
ticks
;
87
release
(&
tickslock
);
88
return
xticks
;
89
}