I've finished the project but it didn't compile. Can someone help me
plz?
I've done the following things:
in the Proc.h file:
1. Three counters are defined (count1, count2 and count3) to track the
number of processes in each user processes queue.
2. The total number of processes is changed to 19 to fit the 3 extra
user queues.
In the Proc.c file:
2.1 enqueue( ) & dequeue( ) functions
In these function, the counters for the user processes are incremented
and decremneted repectively.
2.2 sched( )
In this function, we diffrenciated between the system processes and
the user ones.
PRIVATE void sched(rp, queue, front)
register struct proc *rp; /* process to be scheduled */
int *queue; /* return: queue to use */
int *front; /* return: front or back */
{
/* This function determines the scheduling policy. It is called
whenever a
* process must be added to one of the scheduling queues to decide
where to
* insert it. As a side-effect the process' priority may be
updated.
*/
int time_left = (rp->p_ticks_left > 0); /* quantum fully consumed */
/* Check whether the process has time left. Otherwise give a new
quantum
* and lower the process' priority, unless the process already is in
the
* lowest queue.
*/
if (! time_left) { /* quantum consumed ? */
rp->p_ticks_left = rp->p_quantum_size; /* give new quantum */
if (rp->p_priority < (NR_SCHED_QUEUES-1)) {
if(priv(rp)->s_flags & SYS_PROC){
rp->p_priority += 1; /* lower priority */
}
}
}
/* If there is time left, the process is added to the front of its
queue,
* so that it can immediately run. The queue to use simply is always
the
* process' current priority.
*/
if(priv(rp)->s_flags & SYS_PROC)
{
*front = time_left;
}
else
{
if(rp->p_priority<16)
{
rp->p_priority=16;
}
*front=0;
}
*queue = rp->p_priority;
}
2.3 pick_proc
This function contains the algorithm for the scheduling of the
processes.
PRIVATE struct proc * pick_proc(void)
{
/* Decide who to run now. A new process is selected an returned.
* When a billable process is selected, record it in 'bill_ptr', so
that the
* clock task can tell who to bill for system time.
*/
register struct proc *rp; /* process to run */
int q; /* iterate over queues */
/* Check each of the scheduling queues for ready processes. The
number of
* queues is defined in proc.h, and priorities are set in the task
table.
* The lowest queue contains IDLE, which is always ready.
*/
for (q=0; q < NR_SCHED_QUEUES; q++) {
if(!(rp = rdy_head[q])) {
TRACE(VF_PICKPROC, printf("queue %d empty\n", q););
continue;
}
if(q==16 && count1>0){
rp=rdy_head[q];
}
else if(q==17 && count2>0 && count1==0)
{
rp=rdy_head[q];
}
else if(if(q==18 && count3>0 && count1==0 && count2==0)
{
rp=rdy_head[q];
}
TRACE(VF_PICKPROC, printf("found %s / %d on queue %d\n",
rp->p_name, rp->p_endpoint, q););
vmassert(!proc_is_runnable(rp));
if (priv(rp)->s_flags & BILLABLE)
bill_ptr = rp; /* bill for system time */
return rp;
}
return NULL;
}
In the do_nice
We have added some conditions to put the user processes's priorities
to be from 0 to 2
if (pri < PRIO_MIN || pri > PRIO_MAX) return(EINVAL);
if(priv(rp)->s_flags & SYS_PROC){
new_q = MAX_USER_Q + (pri-PRIO_MIN) * (MIN_USER_Q-MAX_USER_Q+1) /
(PRIO_MAX-PRIO_MIN+1);
if (new_q < MAX_USER_Q) new_q = MAX_USER_Q; /* shouldn't happen */
if (new_q > MIN_USER_Q) new_q = MIN_USER_Q; /* shouldn't happen */
}
else
{
if(pri>2){
pri=2;}
if(pri<0){
pri=0;}
new_q = NR_SCHED_QUEUES+pri;
}
/* Make sure the process is not running while changing its
priority.
* Put the process back in its new queue if it is runnable.
*/
RTS_LOCK_SET(rp, RTS_SYS_LOCK);
rp->p_max_priority = rp->p_priority = new_q;
RTS_LOCK_UNSET(rp, RTS_SYS_LOCK);
return(OK);
}
Any suggestions??
> > Thank you for your reply. Actually it worked andminixstarted but I