I'm trying to implement the priority round robin scheduling system in xv6 after fixing some lock errors which were causing a panic error but now I keep running into a booting error and my kernel gets stuck before booting up completely.
xv6 kernel is booting
hart 2 starting
hart 1 starting
After this my kernel stops booting and gets stuck.
Sometimes the hart starting order changes from 1 then 2 and sometimes 2 then 1 starts.
My scheduler is defined in proc.c as follows:-
scheduler(void)
{
struct proc *p;
struct cpu *c = mycpu();
struct proc *highp = 0;
c->proc = 0;
for(;;){
// Avoid deadlock by ensuring that devices can interrupt.
intr_on();
for(p = proc; p < &proc[NPROC]; p++) {
if (p->state != RUNNABLE)
continue;
if (highp == 0 || p->priority > highp->priority)
highp = p;
if (highp != 0) {
continue;
}
}
if (ticks-lastagingtime > 100) {
struct proc *p;
for (p = proc ; p < &proc[NPROC]; p++) {
if (p->state == SLEEPING || p->state == RUNNABLE)
p->priority++;
}
lastagingtime = ticks;
}
}
}
My setpriority is defined in proc.c as follows:-
setpriority(int pid, int priority)
{
struct proc *p;
for (p = proc; p < &proc[NPROC]; p++) {
if (p->pid == pid) {
p->priority = priority;
}
}
return pid;
}
I acquired a spinlock for looping over process table and then released it in the end then returned the pid value.
Now I keep running into this booting error and my kernel gets stuck.
Any idea how to solve this error or what necessary changes I should make?
I'm a beginner and any inputs would be extremely helpful !