Some important modification(From RR to XQ1):

For creating out Multilevel-Feedback Queue Scheduler, we studied and worked on the Round-Robin Algorithm and the original code. Here are some modifications on the Round-Robin Scheduler code:

 Job priority added.
	For each job can be carried out on a independent priority level.

private int priority;

public int getPriority(){
return priority;
}

public void setPriority(int p){
priority = p;
}

 Priority queue added.
	For storing all ready-state jobs, which are paused by the clock interrupt. Those queues are different from the queue used for store the blocked jobs which waiting for the available system resources.

private Job[] pqHead = new Job[8];
private Job[] pqTail = new Job[8];

 Modify scheduler algorithm.
	Because Round-Robin has no concept of priority, although it’s fair for every job, no matter new arrival, long-waiting job, huge or small, everyone can be carried with same treatment. But it brings some other problems for its limitation of handling the emergency. Urgent job can not be executed soon, it definitely slow down the OS performance for it can not give the system-related job high priority. (Performance will be more worse for multi-user, multi-tasks operating systerm.)

	 Add a job into the priority queues.

public boolean add(Job j, int timeLeft) {
int p = j.getPriority()+1;
if (p == 8)
p = 7;
else if (p > 0)
j.setTimeSlice(2 * j.getTimeSlice());
j.setPriority(p);

if(pqHead[p] == null){
pqHead[p] = j;
}
else{
pqTail[p].next = j;
}
pqTail[p] = j;
j.next = null;
queueChanged(1);
return false;
}

 Take a job out from the priority queue.

public Job remove() {
int i;
for(i=0; i<8; i++){
if(pqHead[i]!=null) {
break;
}
}
if(i==8){
return null;
}
Job result = pqHead[i];
pqHead[i] = pqHead[i].next;
queueChanged(-1);
return result;
}

 Re-write the rescheduling 

public boolean reschedule(Job job) {
for(int i=0; i<8; i++){
if(pqHead[i] != null){
return true;
}
}
return false;
}

some other changes will be directly reflected in the execution of the XQ1 Scheduler.