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

3.4 before add system call

parent ad0e0b5f
...@@ -120,6 +120,7 @@ void userinit(void); ...@@ -120,6 +120,7 @@ void userinit(void);
int wait(void); int wait(void);
void wakeup(void*); void wakeup(void*);
void yield(void); void yield(void);
void clockCounter(void);
// swtch.S // swtch.S
void swtch(struct context**, struct context*); void swtch(struct context**, struct context*);
......
...@@ -271,6 +271,7 @@ exit(void) ...@@ -271,6 +271,7 @@ exit(void)
// Jump into the scheduler, never to return. // Jump into the scheduler, never to return.
curproc->state = ZOMBIE; curproc->state = ZOMBIE;
curproc->timeHandeler.terminationTime = ticks;
sched(); sched();
panic("zombie exit"); panic("zombie exit");
} }
...@@ -559,3 +560,21 @@ procdump(void) ...@@ -559,3 +560,21 @@ procdump(void)
cprintf("\n"); cprintf("\n");
} }
} }
void
clockCounter(){
struct proc* p;
acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state == SLEEPING){
p->timeHandeler.sleepingTime++;
}else if(p->state == RUNNABLE){
p->timeHandeler.runningTime++;
}
else if(p->state ==RUNNING ){
p->timeHandeler.runningTime++;
}
}
release(&ptable.lock);
}
...@@ -37,7 +37,7 @@ idtinit(void) ...@@ -37,7 +37,7 @@ idtinit(void)
void void
trap(struct trapframe *tf) trap(struct trapframe *tf)
{ {
clockCounter();
if(tf->trapno == T_SYSCALL){ if(tf->trapno == T_SYSCALL){
if(myproc()->killed) if(myproc()->killed)
exit(); exit();
......
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