Commit e56c6048 authored by Amir Hosein Kashani's avatar Amir Hosein Kashani

2.1

parent 30dd6b34
......@@ -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(void)
sys_getChildren(int prosecId)
{
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;
}
......
......@@ -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();
}
......@@ -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*);
......
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