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)
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if(p->state != RUNNABLE)
continue;
//choose highest priority
struct proc* minimum = ptable.proc ;
for(p1 = ptable.proc ; p1 <&ptable.proc[NPROC];p1++){
if(p1->state != RUNNABLE){
continue;
if(cpuMode == 2){
//choose highest priority
struct proc* minimum = ptable.proc ;
for(p1 = ptable.proc ; p1 <&ptable.proc[NPROC];p1++){
if(p1->state != RUNNABLE){
continue;
}
if(minimum->calculatedPriority > (p1->calculatedPriority)){
minimum = p1;
}
}
if(minimum->calculatedPriority > (p1->calculatedPriority)){
minimum = p1;
minimum-> calculatedPriority += minimum ->priority;
//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
// to release ptable.lock and then reacquire it
// before jumping back to us.
......
......@@ -12,6 +12,8 @@ struct cpu {
extern struct cpu cpus[NCPU];
extern int ncpu;
extern int cpuMode;// this field show how schedule system use
//PAGEBREAK: 17
// Saved registers for kernel context switches.
......
......@@ -105,7 +105,7 @@ trap(struct trapframe *tf)
currentQuantom++;
if(myproc() && myproc()->state == RUNNING &&
tf->trapno == T_IRQ0+IRQ_TIMER &&
currentQuantom%QUANTUM==0)
(currentQuantom%QUANTUM==0 || cpuMode!= 1) )
yield();
// 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