Commit 117b810a authored by Amir Hosein Kashani's avatar Amir Hosein Kashani

3.3 before add sys_call

parent 8f8d871c
...@@ -336,24 +336,25 @@ scheduler(void) ...@@ -336,24 +336,25 @@ scheduler(void)
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state != RUNNABLE) if(p->state != RUNNABLE)
continue; continue;
if(cpuMode == 2){
//choose highest priority //choose highest priority
struct proc* minimum = ptable.proc ; struct proc* minimum = ptable.proc ;
for(p1 = ptable.proc ; p1 <&ptable.proc[NPROC];p1++){ for(p1 = ptable.proc ; p1 <&ptable.proc[NPROC];p1++){
if(p1->state != RUNNABLE){ if(p1->state != RUNNABLE){
continue; continue;
}
if(minimum->calculatedPriority > (p1->calculatedPriority)){
minimum = p1;
}
} }
if(minimum->calculatedPriority > (p1->calculatedPriority)){ minimum-> calculatedPriority += minimum ->priority;
minimum = p1;
//for controling larg int and destroy negative priority
if(minimum->calculatedPriority<0){
minimum->calculatedPriority = 0;
} }
p = minimum;
} }
minimum-> calculatedPriority += minimum ->priority;
//for controling larg int and destroy negative priority
if(minimum->calculatedPriority<0){
minimum->calculatedPriority = 0;
}
p = minimum;
// Switch to chosen process. It is the process's job // Switch to chosen process. It is the process's job
// to release ptable.lock and then reacquire it // to release ptable.lock and then reacquire it
// before jumping back to us. // before jumping back to us.
......
...@@ -12,6 +12,8 @@ struct cpu { ...@@ -12,6 +12,8 @@ struct cpu {
extern struct cpu cpus[NCPU]; extern struct cpu cpus[NCPU];
extern int ncpu; extern int ncpu;
extern int cpuMode;// this field show how schedule system use
//PAGEBREAK: 17 //PAGEBREAK: 17
// Saved registers for kernel context switches. // Saved registers for kernel context switches.
......
...@@ -105,7 +105,7 @@ trap(struct trapframe *tf) ...@@ -105,7 +105,7 @@ trap(struct trapframe *tf)
currentQuantom++; currentQuantom++;
if(myproc() && myproc()->state == RUNNING && if(myproc() && myproc()->state == RUNNING &&
tf->trapno == T_IRQ0+IRQ_TIMER && tf->trapno == T_IRQ0+IRQ_TIMER &&
currentQuantom%QUANTUM==0) (currentQuantom%QUANTUM==0 || cpuMode!= 1) )
yield(); yield();
// Check if the process has been killed since we yielded // Check if the process has been killed since we yielded
......
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