Class RRScheduler

java.lang.Object
  |
  +--Scheduler
        |
        +--RRScheduler

class RRScheduler
extends Scheduler

A round-robin Scheduler for a CPU. It maintains a linked list of jobs. This scheduler is remarkably similar to the DiskScheduler.


Field Summary
private  Job head
          The head of a queue of jobs awaiting service.
private  Job tail
           
 
Fields inherited from class Scheduler
lastChanged, lenSum, maxLen, MAXQUEUE, qlen, queueHist
 
Constructor Summary
(package private) RRScheduler()
           
 
Method Summary
 boolean add(Job j)
          Add a new job wanting service.
 void printQueue()
          For debugging: print the queue of waiting jobs
private  java.lang.String queueString()
          For debugging.
 Job remove()
          Retrieve (and remove) the next job to be served.
 boolean reschedule(Job j)
          This method is called when there is a clock interrupt, and just after a job changes state.
 
Methods inherited from class Scheduler
printStats, queueChanged
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

head

private Job head
The head of a queue of jobs awaiting service. If the queue is empty, head = null and the value of tail is undefined.

tail

private Job tail
Constructor Detail

RRScheduler

RRScheduler()
Method Detail

add

public boolean add(Job j)
Add a new job wanting service.
Overrides:
add in class Scheduler
Parameters:
j - the job to serve
Returns:
false (this scheduler never preempts)

remove

public Job remove()
Retrieve (and remove) the next job to be served. Return null if there is no such job.
Overrides:
remove in class Scheduler
Tags copied from class: Scheduler
Returns:
the next job (null if there is no such job).

reschedule

public boolean reschedule(Job j)
This method is called when there is a clock interrupt, and just after a job changes state.
Overrides:
reschedule in class Scheduler
Parameters:
j - the job currently being serviced by the corresponding device.
Returns:
true if the scheduler wants to preempt the current job.

printQueue

public void printQueue()
For debugging: print the queue of waiting jobs
Overrides:
printQueue in class Scheduler

queueString

private java.lang.String queueString()
For debugging.
Returns:
a concise version of the queue of waiting jobs