Quantcast
Channel: Active questions tagged operating-system+scheduling - Stack Overflow
Viewing all articles
Browse latest Browse all 211

FCFS scheduler implemention for xv6

$
0
0

I am trying to implement FCFS scheduling algorithms for xv6. The following is the modification i did to the code:

voidscheduler(void){    struct proc *p = 0;    struct cpu *c = mycpu();    c->proc = 0;    for(;;)    {        sti();        struct proc *minP = 0;        // Loop over process table looking for process to run.        acquire(&ptable.lock);        for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)        {            if(p->state != RUNNABLE)                continue;            // ignore init and sh processes from FCFS            if(p->pid > 1)            {                if (minP != 0) {                    // here I find the process with the lowest creation time (the first one that was created)                    if(p->starttime < minP->starttime)                        minP = p;                }                else                    minP = p;                }        }        p = minP;        release(&ptable.lock);        if(p != 0)        {            c->proc = p;            switchuvm(p);            p->state = RUNNING;            swtch(&(c->scheduler), p->context);            switchkvm();            c->proc = 0;        }    }}

when I make clean then make qemu-nox this is all I got:Booting from Hard Disk..xv6...cpu1: starting 1cpu0: starting 0

I suspect it is due to no process running when trying to boot.


Viewing all articles
Browse latest Browse all 211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>