Skip to content

Commit

Permalink
getpinfo start
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruvi-Lodhavia committed Nov 11, 2020
1 parent a4801cb commit 3940a2b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 2 deletions.
4 changes: 3 additions & 1 deletion defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct spinlock;
struct sleeplock;
struct stat;
struct superblock;
struct pstat;

// bio.c
void binit(void);
Expand Down Expand Up @@ -120,9 +121,10 @@ void userinit(void);
int wait(void);
void wakeup(void*);
void yield(void);
int cps(void);
int cps(void);
void mlfq(struct proc**,struct proc**,int*,int*,struct cpu*);
void Boost(void);
int getpinfo(struct pstat*);
// swtch.S
void swtch(struct context**, struct context*);

Expand Down
6 changes: 6 additions & 0 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,9 @@ int cps()
release(&ptable.lock);
return 22;
}

int getpinfo(struct pstat* pstat)
{
;
return 23;
}
17 changes: 17 additions & 0 deletions pstat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#include "proc.h"
#include "param.h"


struct pstat{
int inuse[NPROC]; // whether this slot of the process table is in use (1 or 0)
int pid[NPROC]; // PID of each process
int priority[NPROC]; // current priority level of each process (0-3)
enum procstate state[NPROC]; // current state (e.g., SLEEPING or RUNNABLE) of each process
int ticks[NPROC][4]; // number of ticks each process has accumulated at each of 4 priorities
};

typedef struct pstat pstat;
// extern struct pstat pstat_var;


3 changes: 3 additions & 0 deletions syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ extern int sys_wait(void);
extern int sys_write(void);
extern int sys_uptime(void);
extern int sys_cps(void);
extern int sys_getpinfo(void);

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

};

void
Expand Down
1 change: 1 addition & 0 deletions syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
#define SYS_mkdir 20
#define SYS_close 21
#define SYS_cps 22
#define SYS_getpinfo 23
10 changes: 10 additions & 0 deletions sysproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "memlayout.h"
#include "mmu.h"
#include "proc.h"
#include "pstat.h"

int
sys_fork(void)
Expand Down Expand Up @@ -93,4 +94,13 @@ int
sys_cps(void)
{
return cps();
}
int
sys_getpinfo(void)
{
struct pstat* pstat;

if(argptr(1, (void*)&pstat, sizeof(*pstat)) < 0)
return -1;
return getpinfo(pstat);
}
3 changes: 2 additions & 1 deletion user.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct stat;
struct rtcdate;

struct pstat;
// system calls
int fork(void);
int exit(void) __attribute__((noreturn));
Expand All @@ -24,6 +24,7 @@ char* sbrk(int);
int sleep(int);
int uptime(void);
int cps(void);
int getpinfo(struct pstat*);

// ulib.c
int stat(const char*, struct stat*);
Expand Down
1 change: 1 addition & 0 deletions usys.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ SYSCALL(sbrk)
SYSCALL(sleep)
SYSCALL(uptime)
SYSCALL(cps)
SYSCALL(getpinfo)

0 comments on commit 3940a2b

Please sign in to comment.