Commit 7ec127fe authored by Amir Hosein Kashani's avatar Amir Hosein Kashani

start of phase 3

parent 837b5275
...@@ -183,7 +183,8 @@ UPROGS=\ ...@@ -183,7 +183,8 @@ UPROGS=\
_usertests\ _usertests\
_wc\ _wc\
_zombie\ _zombie\
_test\ _getChildrenTest\
_getCountTest\
fs.img: mkfs README $(UPROGS) fs.img: mkfs README $(UPROGS)
./mkfs fs.img README $(UPROGS) ./mkfs fs.img README $(UPROGS)
...@@ -252,7 +253,7 @@ qemu-nox-gdb: fs.img xv6.img .gdbinit ...@@ -252,7 +253,7 @@ qemu-nox-gdb: fs.img xv6.img .gdbinit
EXTRA=\ EXTRA=\
mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c kill.c\ 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\test.c\ ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c zombie.c\getChildrenTest.c\_getCountTest\
printf.c umalloc.c\ printf.c umalloc.c\
README dot-bochsrc *.pl toc.* runoff runoff1 runoff.list\ README dot-bochsrc *.pl toc.* runoff runoff1 runoff.list\
.gdbinit.tmpl gdbutil\ .gdbinit.tmpl gdbutil\
......
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
int int
main(int argc,char **argv) main(int argc,char **argv)
{ {
int a= fork(); int a= fork();
fork(); fork();
fork(); fork();
fork();
wait(); wait();
wait(); wait();
wait(); wait();
int b = getChildren(a); int b = getChildren(a);
printf(1,"***** %d ********\n",b); printf(1,"pid %d =*****ppid=%d //\n",getpid(),b);
printf(1, "My first xv6 program\n"); wait();
// printf(1, "My first xv6 program\n");
//for question one testing :) here is finished
exit(); exit();
} }
#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
...@@ -104,6 +104,7 @@ extern int sys_wait(void); ...@@ -104,6 +104,7 @@ extern int sys_wait(void);
extern int sys_write(void); extern int sys_write(void);
extern int sys_uptime(void); extern int sys_uptime(void);
extern int sys_getChildren(void); extern int sys_getChildren(void);
extern int sys_getCount(void);
static int (*syscalls[])(void) = { static int (*syscalls[])(void) = {
[SYS_fork] sys_fork, [SYS_fork] sys_fork,
...@@ -128,6 +129,7 @@ static int (*syscalls[])(void) = { ...@@ -128,6 +129,7 @@ static int (*syscalls[])(void) = {
[SYS_mkdir] sys_mkdir, [SYS_mkdir] sys_mkdir,
[SYS_close] sys_close, [SYS_close] sys_close,
[SYS_getChildren] sys_getChildren, [SYS_getChildren] sys_getChildren,
[SYS_getCount] sys_getCount
}; };
void void
......
...@@ -21,3 +21,4 @@ ...@@ -21,3 +21,4 @@
#define SYS_mkdir 20 #define SYS_mkdir 20
#define SYS_close 21 #define SYS_close 21
#define SYS_getChildren 22 #define SYS_getChildren 22
#define SYS_getCount 23
...@@ -125,6 +125,19 @@ sys_getChildren(int prosecId) ...@@ -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;
}
......
...@@ -24,6 +24,7 @@ char* sbrk(int); ...@@ -24,6 +24,7 @@ char* sbrk(int);
int sleep(int); int sleep(int);
int uptime(void); int uptime(void);
int getChildren(int); int getChildren(int);
int getCount(int);
// ulib.c // ulib.c
int stat(const char*, struct stat*); int stat(const char*, struct stat*);
......
...@@ -30,3 +30,4 @@ SYSCALL(sbrk) ...@@ -30,3 +30,4 @@ SYSCALL(sbrk)
SYSCALL(sleep) SYSCALL(sleep)
SYSCALL(uptime) SYSCALL(uptime)
SYSCALL(getChildren) SYSCALL(getChildren)
SYSCALL(getCount)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment