lundi 2 mars 2015

Context Switching and Timer Interrupts in xv6



I am trying to modify the scheduling policy in xv6 in which Parent runs first after forking.



childPid = fork();
if (childPid < 0)
{
printf("fork() is failed\n");
}
else if (childPid == 0) // child
{
printf(" child! ");
exit();
}

printf(" parent! ");


As the scheduler of xv6 always run Parent first i need to context switch to child first so that child will run first and after that parent will run. I have tried using wait() in the code but the wait will fail and i do not want to use fail. I need to modify the context switch when fork is performed by my user level program.


In the xv6 fork() system call i have made the following changes



acquire(&ptable.lock);
np->state = RUNNABLE;
swtch(&cpu->scheduler, proc->context);
release(&ptable.lock);


but this does not seems to work. Does it have something to do with timer interrupts. How can i achieve to run child first in fork after doing context switching.




Aucun commentaire:

Enregistrer un commentaire