Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
OS_XV6
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9631059
OS_XV6
Commits
e56c6048
Commit
e56c6048
authored
Dec 15, 2019
by
Amir Hosein Kashani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.1
parent
30dd6b34
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
14 deletions
+44
-14
sysproc.c
sysproc.c
+34
-10
test.c
test.c
+9
-1
user.h
user.h
+1
-3
No files found.
sysproc.c
View file @
e56c6048
...
...
@@ -7,13 +7,29 @@
#include "mmu.h"
#include "proc.h"
int
table
[
1200
][
256
]
=
{
0
};
int
sys_getpid
(
void
)
{
return
myproc
()
->
pid
;
}
int
sys_fork
(
void
)
{
int
dadPid
=
pid
;
int
dadPid
=
sys_getpid
()
;
int
pidChild
=
fork
();
return
//cprintf("father : %d child : %d",dadPid , pidChild);
for
(
int
i
=
0
;
i
<
256
;
i
++
){
if
(
table
[
dadPid
][
i
]
==
0
){
table
[
dadPid
][
i
]
=
pidChild
;
break
;
}
}
return
pidChild
;
}
int
...
...
@@ -39,11 +55,7 @@ sys_kill(void)
return
kill
(
pid
);
}
int
sys_getpid
(
void
)
{
return
myproc
()
->
pid
;
}
int
sys_sbrk
(
void
)
...
...
@@ -95,9 +107,21 @@ sys_uptime(void)
//my implimentation
int
sys_getChildren
(
voi
d
)
sys_getChildren
(
int
prosecI
d
)
{
return
120
;
int
result
=
0
;
argint
(
0
,
&
prosecId
);
int
j
=
0
;
while
(
table
[
prosecId
][
j
]
!=
0
){
int
temp
=
table
[
prosecId
][
j
];
while
(
temp
>
0
){
temp
/=
10
;
result
*=
10
;
}
result
+=
table
[
prosecId
][
j
];
j
++
;
}
return
result
;
}
...
...
test.c
View file @
e56c6048
...
...
@@ -3,8 +3,16 @@
#include "user.h"
int
main
(
void
)
main
(
int
argc
,
char
**
argv
)
{
int
a
=
fork
();
fork
();
fork
();
wait
();
wait
();
wait
();
int
b
=
getChildren
(
a
);
printf
(
1
,
"***** %d ********
\n
"
,
b
);
printf
(
1
,
"My first xv6 program
\n
"
);
exit
();
}
user.h
View file @
e56c6048
...
...
@@ -23,9 +23,7 @@ int getpid(void);
char
*
sbrk
(
int
);
int
sleep
(
int
);
int
uptime
(
void
);
int
getChildren
(
void
);
int
getChildren
(
int
);
// ulib.c
int
stat
(
const
char
*
,
struct
stat
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment