. fixed a recently introduced scheduler (run-queue) bug in proc.c
. a little (optional) debugging code added to proc.c and associated data in proc.h
This commit is contained in:
parent
0f55ebe90a
commit
168b7f2669
@ -415,6 +415,13 @@ register struct proc *rp; /* this process is now runnable */
|
|||||||
/* Add 'rp' to one of the queues of runnable processes. */
|
/* Add 'rp' to one of the queues of runnable processes. */
|
||||||
int q = rp->p_priority; /* scheduling queue to use */
|
int q = rp->p_priority; /* scheduling queue to use */
|
||||||
|
|
||||||
|
#if ENABLE_K_DEBUGGING
|
||||||
|
if(rp->p_ready) {
|
||||||
|
kprintf("ready() already ready process\n", NO_NUM);
|
||||||
|
}
|
||||||
|
rp->p_ready = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Processes, in principle, are added to the end of the queue. However,
|
/* Processes, in principle, are added to the end of the queue. However,
|
||||||
* user processes are added in front of the queue, because this is a bit
|
* user processes are added in front of the queue, because this is a bit
|
||||||
* fairer to I/O bound processes.
|
* fairer to I/O bound processes.
|
||||||
@ -453,6 +460,13 @@ register struct proc *rp; /* this process is no longer runnable */
|
|||||||
register struct proc **qtail; /* queue's rdy_tail */
|
register struct proc **qtail; /* queue's rdy_tail */
|
||||||
int q = rp->p_priority; /* queue to use */
|
int q = rp->p_priority; /* queue to use */
|
||||||
|
|
||||||
|
#if ENABLE_K_DEBUGGING
|
||||||
|
if(!rp->p_ready) {
|
||||||
|
kprintf("unready() already unready process\n", NO_NUM);
|
||||||
|
}
|
||||||
|
rp->p_ready = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Side-effect for tasks: check if the task's stack still is ok? */
|
/* Side-effect for tasks: check if the task's stack still is ok? */
|
||||||
if (istaskp(rp)) {
|
if (istaskp(rp)) {
|
||||||
if (*rp->p_stguard != STACK_GUARD)
|
if (*rp->p_stguard != STACK_GUARD)
|
||||||
@ -468,16 +482,19 @@ register struct proc *rp; /* this process is no longer runnable */
|
|||||||
rdy_head[q] = xp->p_nextready; /* new head of queue */
|
rdy_head[q] = xp->p_nextready; /* new head of queue */
|
||||||
if (rp == proc_ptr) /* current process removed */
|
if (rp == proc_ptr) /* current process removed */
|
||||||
pick_proc(); /* pick new process to run */
|
pick_proc(); /* pick new process to run */
|
||||||
}
|
if(rp == rdy_tail[q])
|
||||||
|
rdy_tail[q] = NIL_PROC;
|
||||||
|
}
|
||||||
else { /* check body of queue */
|
else { /* check body of queue */
|
||||||
while (xp->p_nextready != rp) /* stop if process is next */
|
while (xp->p_nextready != rp) /* stop if process is next */
|
||||||
if ( (xp = xp->p_nextready) == NIL_PROC)
|
if ( (xp = xp->p_nextready) == NIL_PROC)
|
||||||
return;
|
return;
|
||||||
xp->p_nextready = xp->p_nextready->p_nextready;
|
xp->p_nextready = xp->p_nextready->p_nextready;
|
||||||
if (rdy_tail[q] == rp) /* possibly update tail */
|
if (rdy_tail[q] == rp) /* possibly update tail */
|
||||||
rdy_tail[q] = rp;
|
rdy_tail[q] = xp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
@ -62,6 +62,10 @@ struct proc {
|
|||||||
unsigned p_pendcount; /* count of pending and unfinished signals */
|
unsigned p_pendcount; /* count of pending and unfinished signals */
|
||||||
|
|
||||||
char p_name[PROC_NAME_LEN]; /* name of the process, including \0 */
|
char p_name[PROC_NAME_LEN]; /* name of the process, including \0 */
|
||||||
|
|
||||||
|
#if ENABLE_K_DEBUGGING
|
||||||
|
int p_ready, p_found;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Guard word for task stacks. */
|
/* Guard word for task stacks. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user