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
7ec127fe
Commit
7ec127fe
authored
Dec 16, 2019
by
Amir Hosein Kashani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start of phase 3
parent
837b5275
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
5 deletions
+42
-5
Makefile
Makefile
+3
-2
getChildrenTest.c
getChildrenTest.c
+5
-3
getCountTest.c
getCountTest.c
+16
-0
syscall.c
syscall.c
+2
-0
syscall.h
syscall.h
+1
-0
sysproc.c
sysproc.c
+13
-0
user.h
user.h
+1
-0
usys.S
usys.S
+1
-0
No files found.
Makefile
View file @
7ec127fe
...
...
@@ -183,7 +183,8 @@ UPROGS=\
_usertests
\
_wc
\
_zombie
\
_test
\
_getChildrenTest
\
_getCountTest
\
fs.img
:
mkfs README $(UPROGS)
./mkfs fs.img README
$(UPROGS)
...
...
@@ -252,7 +253,7 @@ qemu-nox-gdb: fs.img xv6.img .gdbinit
EXTRA
=
\
mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c kill.c
\
ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c zombie.c
\
t
est.c
\
ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c zombie.c
\
g
etChildrenTest.c
\_
getCountTest
\
printf.c umalloc.c
\
README dot-bochsrc
*
.pl toc.
*
runoff runoff1 runoff.list
\
.gdbinit.tmpl gdbutil
\
...
...
t
est.c
→
getChildrenT
est.c
View file @
7ec127fe
#include "types.h"
#include "stat.h"
#include "user.h"
int
main
(
int
argc
,
char
**
argv
)
{
int
a
=
fork
();
fork
();
fork
();
fork
();
wait
();
wait
();
wait
();
int
b
=
getChildren
(
a
);
printf
(
1
,
"***** %d ********
\n
"
,
b
);
printf
(
1
,
"My first xv6 program
\n
"
);
printf
(
1
,
"pid %d =*****ppid=%d //
\n
"
,
getpid
(),
b
);
wait
();
// printf(1, "My first xv6 program\n");
//for question one testing :) here is finished
exit
();
}
getCountTest.c
0 → 100644
View file @
7ec127fe
#include "types.h"
#include "stat.h"
#include "user.h"
int
main
(
int
argc
,
char
**
argv
)
{
int
a
=
4
;
getChildren
(
a
);
getChildren
(
a
);
int
test
=
readcommand
(
0
,
command
,
args
);
printf
(
"i find this %d"
,
test
);
int
result
=
getCount
(
22
);
printf
(
1
,
"--- %d ---"
,
result
);
exit
();
}
\ No newline at end of file
syscall.c
View file @
7ec127fe
...
...
@@ -104,6 +104,7 @@ extern int sys_wait(void);
extern
int
sys_write
(
void
);
extern
int
sys_uptime
(
void
);
extern
int
sys_getChildren
(
void
);
extern
int
sys_getCount
(
void
);
static
int
(
*
syscalls
[])(
void
)
=
{
[
SYS_fork
]
sys_fork
,
...
...
@@ -128,6 +129,7 @@ static int (*syscalls[])(void) = {
[
SYS_mkdir
]
sys_mkdir
,
[
SYS_close
]
sys_close
,
[
SYS_getChildren
]
sys_getChildren
,
[
SYS_getCount
]
sys_getCount
};
void
...
...
syscall.h
View file @
7ec127fe
...
...
@@ -21,3 +21,4 @@
#define SYS_mkdir 20
#define SYS_close 21
#define SYS_getChildren 22
#define SYS_getCount 23
sysproc.c
View file @
7ec127fe
...
...
@@ -125,6 +125,19 @@ sys_getChildren(int prosecId)
}
//question 2
int
sys_getCount
(
int
find
){
argint
(
0
,
&
find
);
int
counter
=
0
;
for
(
int
i
=
0
;
i
<=
myproc
()
->
usagepointer
;
i
++
){
if
(
myproc
()
->
usage
[
i
]
==
find
){
counter
++
;
}
}
return
counter
;
}
...
...
user.h
View file @
7ec127fe
...
...
@@ -24,6 +24,7 @@ char* sbrk(int);
int
sleep
(
int
);
int
uptime
(
void
);
int
getChildren
(
int
);
int
getCount
(
int
);
// ulib.c
int
stat
(
const
char
*
,
struct
stat
*
);
...
...
usys.S
View file @
7ec127fe
...
...
@@ -30,3 +30,4 @@ SYSCALL(sbrk)
SYSCALL(sleep)
SYSCALL(uptime)
SYSCALL(getChildren)
SYSCALL(getCount)
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