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

3.1 finished

parent 7ec127fe
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
#define LOGSIZE (MAXOPBLOCKS*3) // max data blocks in on-disk log #define LOGSIZE (MAXOPBLOCKS*3) // max data blocks in on-disk log
#define NBUF (MAXOPBLOCKS*3) // size of disk block cache #define NBUF (MAXOPBLOCKS*3) // size of disk block cache
#define FSSIZE 1000 // size of file system in blocks #define FSSIZE 1000 // size of file system in blocks
#define QUANTUM 10 //number of ticks that cpu must wait on current procces
...@@ -13,7 +13,7 @@ struct gatedesc idt[256]; ...@@ -13,7 +13,7 @@ struct gatedesc idt[256];
extern uint vectors[]; // in vectors.S: array of 256 entry pointers extern uint vectors[]; // in vectors.S: array of 256 entry pointers
struct spinlock tickslock; struct spinlock tickslock;
uint ticks; uint ticks;
int currentQuantom ; //show us how many quantom passed in this procces
void void
tvinit(void) tvinit(void)
{ {
...@@ -102,8 +102,10 @@ trap(struct trapframe *tf) ...@@ -102,8 +102,10 @@ trap(struct trapframe *tf)
// Force process to give up CPU on clock tick. // Force process to give up CPU on clock tick.
// If interrupts were on while locks held, would need to check nlock. // If interrupts were on while locks held, would need to check nlock.
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)
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