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

add struct for timing

parent c9a111a5
......@@ -10,5 +10,9 @@ main(int argc,char **argv)
getChildren(a);
int result = getCount(22);
printf(1,"--- %d ---",result);
exit();
//this code for test of 3.3
/*
changePolicy(1);
changePolicy(2);
exit();*/
}
\ No newline at end of file
......@@ -112,6 +112,14 @@ found:
memset(p->context, 0, sizeof *p->context);
p->context->eip = (uint)forkret;
//kashaia
p->timeHandeler.creationTime = ticks;
p ->timeHandeler.runningTime =0;
p->timeHandeler.sleepingTime = 0 ;
p->timeHandeler.readyTime = 0;
return p;
}
......
......@@ -34,10 +34,20 @@ struct context {
uint eip;
};
struct timeVariables{//this struct for 3.4
int creationTime;
int terminationTime;
int sleepingTime;
int readyTime;
int runningTime;
};
enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE };
// Per-process state
struct proc {
struct timeVariables timeHandeler;
int usagepointer;
int usage[100];
int priority;
......
......@@ -106,6 +106,7 @@ extern int sys_uptime(void);
extern int sys_getChildren(void);
extern int sys_getCount(void);
extern int sys_changePriority(void);
extern int sys_changePolicy(void);
static int (*syscalls[])(void) = {
[SYS_fork] sys_fork,
......@@ -131,7 +132,8 @@ static int (*syscalls[])(void) = {
[SYS_close] sys_close,
[SYS_getChildren] sys_getChildren,
[SYS_getCount] sys_getCount,
[SYS_changePriority] sys_changePriority
[SYS_changePriority] sys_changePriority,
[SYS_changePolicy] sys_changePolicy,
};
void
......
......@@ -23,3 +23,4 @@
#define SYS_getChildren 22
#define SYS_getCount 23
#define SYS_changePriority 24
#define SYS_changePolicy 25
......@@ -8,7 +8,7 @@
#include "proc.h"
int table[1200][256] ={0};
extern int cpuMode;
int
sys_getpid(void)
{
......@@ -152,6 +152,18 @@ sys_changePriority(int newPriority){
return 5;
}
//3.3
int
sys_changePolicy(int mode){
argint(0,&mode);
if(mode>2 || mode<0){
return -1;
}
cprintf("%d",cpuMode);
cpuMode = mode;
return 1;
}
......
......@@ -37,6 +37,7 @@ idtinit(void)
void
trap(struct trapframe *tf)
{
if(tf->trapno == T_SYSCALL){
if(myproc()->killed)
exit();
......@@ -46,7 +47,6 @@ trap(struct trapframe *tf)
exit();
return;
}
switch(tf->trapno){
case T_IRQ0 + IRQ_TIMER:
if(cpuid() == 0){
......
......@@ -26,6 +26,7 @@ int uptime(void);
int getChildren(int);
int getCount(int);
int changePriority(int);
int changePolicy(int);
// ulib.c
int stat(const char*, struct stat*);
......
......@@ -32,3 +32,4 @@ SYSCALL(uptime)
SYSCALL(getChildren)
SYSCALL(getCount)
SYSCALL(changePriority)
SYSCALL(changePolicy)
\ No newline at end of file
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