我将如何从FCFS转换为Round Robin?

时间:2019-03-28 04:53:02

标签: java linked-list operating-system round-robin

据我所知,FCFS和Round Robin的唯一区别在于以下事实:一个使用“时间片”,因此一个进程每次运行时间只能使用该时间量。

请找到我的FCFS调度程序:

import java.util.Queue;
import java.util.LinkedList;

public class Fcfs extends Scheduler {

  private Queue<Process> readyQueue;


  public Fcfs() {
    readyQueue = new LinkedList<Process>();
  }

  //adds a process to the ready queue
  public void ready(Process process, boolean finTimeQuantum) {
    readyQueue.offer(process);
  }

  //removes the next process to be run from the ready queue and returns it
  public Process schedule() {
    System.out.println("Scheduler selects process "+readyQueue.peek());
    return readyQueue.poll();
  }
}

现在我已经完成了此操作,我不明白一个人如何实现切片的?我会继续像这样

public class Rr extends Scheduler {
    private Queue<Process> readyQueue;
    private final int quantum; //this is the slicer
    private int i; //assuming I need a counter

    public Rr() {
        readyQueue = new LinkedList<Process>();
        quantum = super.getTimeQuantum();

    //Process process gives you process with parameters
    //boolean finTimeQuantum is true if process is being moved to ready after having fully its quantum.
    public void ready(Process process, boolean finTimeQuantum) {
        //though now I've no idea what to do?

在我现在做循环赛的时候,我会假设我不去,并立即.offer()出现的第一个过程。或者也许是吗?

0 个答案:

没有答案