Skip to content

Commit

Permalink
System calls commented
Browse files Browse the repository at this point in the history
  • Loading branch information
uditvyas committed Nov 28, 2020
1 parent 2117f06 commit 64656ae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 49 deletions.
45 changes: 6 additions & 39 deletions foo.c
Original file line number Diff line number Diff line change
@@ -1,43 +1,13 @@
// TEST FILE, WHICH CREATES A CHILD AND A PARENT PROCESS
// BOTH PARENT AND THE CHILD HAVE CPU INTENSIVE JOBS
// THE PARENT WAIT FOR THE CHILD TO FINISH BEFORE COMPLETING ITS EXECUTION

#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
int
main(int argc, char *argv[]){
// int k, n, id;
// double x = 0, z, d;
// if (argc<2)
// n = 1;
// else
// n = atoi(argv[1]);

// if (n<0||n>20)
// n = 2;
// if (argc<3)
// d = 1.0;
// else
// d = atoi(argv[2]);

// x = 0;
// id = 0;
// for (k=0;k<n;k++){
// id = fork();
// if (id<0){
// printf(1,"%d failed in fork!\n",getpid());
// }
// else if (id>0){
// wait();
// printf(1, "%d Creating Child %d\n",getpid(),id);

// }
// else{
// printf(1, "Child %d created\n", getpid());
// for (z = 0; z<8000000; z+=d ){
// x = x + 3.14*89.64;
// break;
// }
// }
// }
int main(int argc, char *argv[]){
int id = 0;
double x = 1;
id = fork();
Expand All @@ -49,15 +19,12 @@ main(int argc, char *argv[]){
x = x+0.000000005;
}
wait();
// printf(1, "%d Creating Child %d\n",getpid(),id);

}
else{
// printf(1, "Child %d created\n", getpid());
while(x<1.2){
x = x+0.000000005;
}

}
}
exit();
}
8 changes: 0 additions & 8 deletions foo1.c

This file was deleted.

9 changes: 8 additions & 1 deletion syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ extern int sys_wait(void);
extern int sys_write(void);
extern int sys_uptime(void);
extern int sys_cps(void);

/*MLFQ MODIFICATION*/
extern int sys_getpinfo(void);
/*------- END -------*/

static int (*syscalls[])(void) = {
[SYS_fork] sys_fork,
Expand All @@ -129,10 +132,13 @@ static int (*syscalls[])(void) = {
[SYS_mkdir] sys_mkdir,
[SYS_close] sys_close,
[SYS_cps] sys_cps,
[SYS_getpinfo] sys_getpinfo,

/*MLFQ MODIFICATION*/
[SYS_getpinfo] sys_getpinfo,
/*------- END -------*/
};

/*MLFQ MODIFICATION*/
void
syscall(void)
{
Expand All @@ -148,3 +154,4 @@ syscall(void)
curproc->tf->eax = -1;
}
}
/*------- END -------*/
4 changes: 3 additions & 1 deletion syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
#define SYS_mkdir 20
#define SYS_close 21
#define SYS_cps 22
#define SYS_getpinfo 23
/*MLFQ MODIFICATION*/
#define SYS_getpinfo 23
/*------- END -------*/
3 changes: 3 additions & 0 deletions user.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ char* sbrk(int);
int sleep(int);
int uptime(void);
int cps(void);

/*MLFQ MODIFICATION*/
int getpinfo(struct pstat*);
/*------- END -------*/

// ulib.c
int stat(const char*, struct stat*);
Expand Down

0 comments on commit 64656ae

Please sign in to comment.