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);
int wait(void);
void wakeup(void*);
void yield(void);
void clockCounter(void);
// swtch.S
void swtch(struct context**, struct context*);
......
......@@ -271,6 +271,7 @@ exit(void)
// Jump into the scheduler, never to return.
curproc->state = ZOMBIE;
curproc->timeHandeler.terminationTime = ticks;
sched();
panic("zombie exit");
}
......@@ -559,3 +560,21 @@ procdump(void)
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)
void
trap(struct trapframe *tf)
{
clockCounter();
if(tf->trapno == T_SYSCALL){
if(myproc()->killed)
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