Skip to content

Commit

Permalink
add: start sysinfo for lab two
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhe819 committed Jun 14, 2022
1 parent d369366 commit 33d3d51
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ UPROGS=\
$U/_grind\
$U/_wc\
$U/_zombie\
$U/_trace
$U/_trace\
$U/_sysinfotest



Expand Down
3 changes: 3 additions & 0 deletions kernel/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ extern uint64 sys_wait(void);
extern uint64 sys_write(void);
extern uint64 sys_uptime(void);
extern uint64 sys_trace(void);
extern uint64 sys_sysinfo(void);

static uint64 (*syscalls[])(void) = {
[SYS_fork] sys_fork,
Expand All @@ -129,6 +130,7 @@ static uint64 (*syscalls[])(void) = {
[SYS_mkdir] sys_mkdir,
[SYS_close] sys_close,
[SYS_trace] sys_trace,
[SYS_sysinfo] sys_sysinfo,
};

// translate from the above system call function names
Expand All @@ -155,6 +157,7 @@ static char *syscalls_name[] = {
[SYS_mkdir] "mkdir",
[SYS_close] "close",
[SYS_trace] "trace",
[SYS_sysinfo] "sysinfo",
};

void
Expand Down
3 changes: 2 additions & 1 deletion kernel/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
#define SYS_link 19
#define SYS_mkdir 20
#define SYS_close 21
#define SYS_trace 22
#define SYS_trace 22
#define SYS_sysinfo 23
2 changes: 2 additions & 0 deletions user/user.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
struct stat;
struct rtcdate;
struct sysinfo;

// system calls
int fork(void);
Expand All @@ -24,6 +25,7 @@ char* sbrk(int);
int sleep(int);
int uptime(void);
int trace(int);
int sysinfo(struct sysinfo *);

// ulib.c
int stat(const char*, struct stat*);
Expand Down
1 change: 1 addition & 0 deletions user/usys.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ sub entry {
entry("sleep");
entry("uptime");
entry("trace");
entry("sysinfo");

0 comments on commit 33d3d51

Please sign in to comment.