Skip to content

Commit

Permalink
Boost working!
Browse files Browse the repository at this point in the history
  • Loading branch information
Rwik2000 committed Nov 9, 2020
1 parent de54a99 commit b6f7041
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ UPROGS=\
_wc\
_ps\
_zombie\
_foo1\

fs.img: mkfs README $(UPROGS)
./mkfs fs.img README $(UPROGS)
Expand Down Expand Up @@ -251,7 +252,7 @@ qemu-nox-gdb: fs.img xv6.img .gdbinit
EXTRA=\
mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c kill.c\
ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c ps.c zombie.c\
printf.c umalloc.c\
printf.c umalloc.c foo1.c\
README dot-bochsrc *.pl toc.* runoff runoff1 runoff.list\
.gdbinit.tmpl gdbutil\

Expand Down
8 changes: 8 additions & 0 deletions foo1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>

int main(){
int j=0;
for(int i=0;i<10000000;i++){
j++;
}
}
5 changes: 3 additions & 2 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ BOOST
void
Boost(void)
{
//cprintf("Boosting");
// cprintf("Boosting\n");

struct proc *p;
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if (p->priority!=0){
Expand All @@ -370,7 +371,7 @@ Boost(void)

// Remove all process from other queues
q1=q2=q3=-1;
yield();
// yield();
}

/*
Expand Down
46 changes: 34 additions & 12 deletions trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct spinlock tickslock;
uint ticks;
uint xticks;
uint diff = 0;
uint boost_count=0;

void
tvinit(void)
Expand Down Expand Up @@ -108,22 +109,43 @@ trap(struct trapframe *tf)

// Force process to give up CPU on clock tick.
// If interrupts were on while locks held, would need to check nlock.

if(tf->trapno == T_IRQ0+IRQ_TIMER){
acquire(&tickslock);
xticks = ticks;

//cprintf("num of ticks is %d \n",xticks);
release(&tickslock);
// if(xticks/100 - diff/100 > 0)
if(xticks - diff >= 500)
{
//cprintf("Going in boost\n");
diff = xticks;
// cprintf("%d\n", xticks);
boost_count++;
// cprintf("%d\n",boost_count);
Boost();
}
}

if(myproc() && myproc()->state == RUNNING &&
tf->trapno == T_IRQ0+IRQ_TIMER)
{
acquire(&tickslock);
xticks = ticks;
// acquire(&tickslock);
// xticks = ticks;

//cprintf("num of ticks is %d \n",xticks);
release(&tickslock);
if(xticks/100 - diff/100 > 0)
{
//cprintf("Going in boost\n");
diff = xticks;
Boost();
}
diff = xticks;
// //cprintf("num of ticks is %d \n",xticks);
// release(&tickslock);
// // if(xticks/100 - diff/100 > 0)
// if(xticks - diff >= 100)
// {
// //cprintf("Going in boost\n");
// diff = xticks;
// // cprintf("%d\n", xticks);
// boost_count++;
// cprintf("%d\n",boost_count);
// Boost();
// }
// diff = xticks;
//cprintf("Idhar yield hoga!\n");
yield();
}
Expand Down

0 comments on commit b6f7041

Please sign in to comment.