scheduler-simulator

git clone git://git.codymlewis.com/scheduler-simulator.git
Log | Files | Refs | README

commit f9218f91f9f2e5857a1cdb2d75f641644f9dec90
parent d3887d8c15746f1ab207f8b1385ab2c69ddf25ce
Author: Cody Lewis <cody@codymlewis.com>
Date:   Sun,  1 Sep 2019 17:26:44 +1000

Neatened the main class and improved comments

Diffstat:
MA1.java | 28++++++++++------------------
MDispatcher.java | 2+-
MFB.java | 2+-
MFCFS.java | 2+-
MInvalidDataException.java | 2+-
MNRR.java | 2+-
MRR.java | 5+++--
MReport.md | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
MScheduler.java | 2+-
MSortbyPid.java | 2+-
10 files changed, 77 insertions(+), 29 deletions(-)

diff --git a/A1.java b/A1.java @@ -19,28 +19,20 @@ public class A1 { System.exit(1); } - System.out.println("FCFS:"); - Dispatcher fcfs = new Dispatcher("FCFS", args[0]); - System.out.println(fcfs.run()); + String[] dispatcherNames = {"FCFS", "RR", "FB", "NRR"}; + Dispatcher[] dispatchers = new Dispatcher[dispatcherNames.length]; - System.out.println("RR:"); - Dispatcher rr = new Dispatcher("RR", args[0]); - System.out.println(rr.run()); - - System.out.println("FB (constant):"); - Dispatcher fb = new Dispatcher("FB", args[0]); - System.out.println(fb.run()); - - System.out.println("NRR:"); - Dispatcher nrr = new Dispatcher("NRR", args[0]); - System.out.println(nrr.run()); + for (int i = 0; i < dispatcherNames.length; ++i) { + System.out.println(String.format("%s:", dispatcherNames[i])); + dispatchers[i] = new Dispatcher(dispatcherNames[i], args[0]); + System.out.println(dispatchers[i].run()); + } System.out.println("Summary"); System.out.println("Algorithm\tAverage Turnaround Time\tAverage Waiting Time"); - System.out.format("FCFS\t\t%s\n", fcfs.summary()); - System.out.format("RR\t\t%s\n", rr.summary()); - System.out.format("FB (constant)\t%s\n", fb.summary()); - System.out.format("NRR\t\t%s\n", nrr.summary()); + for (int i = 0; i < dispatcherNames.length; ++i) { + System.out.format("%s\t\t%s\n", dispatcherNames[i], dispatchers[i].summary()); + } System.exit(0); } diff --git a/Dispatcher.java b/Dispatcher.java @@ -11,7 +11,7 @@ import java.io.File; * A class for the Dispatcher, it manages the process execution simulation and * is composed of a scheduler. * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */ diff --git a/FB.java b/FB.java @@ -7,7 +7,7 @@ import java.util.Collections; * * The Feedback scheduler * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */ diff --git a/FCFS.java b/FCFS.java @@ -6,7 +6,7 @@ import java.util.Queue; * * The first come fist served scheduler * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */ diff --git a/InvalidDataException.java b/InvalidDataException.java @@ -3,7 +3,7 @@ * * Exception to be called when the data file is formatted incorrectly * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */ diff --git a/NRR.java b/NRR.java @@ -7,7 +7,7 @@ import java.util.Collections; * * The narrow round robin scheduler * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */ diff --git a/RR.java b/RR.java @@ -7,7 +7,7 @@ import java.util.Collections; * * The round robin scheduler * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */ @@ -148,7 +148,8 @@ public class RR extends Scheduler { if (newProcess && !prevPid.equals(head.getProcess().getPid())) { return switchProcess(time); } else { - int processingTime = head.getProcess().process(time, SLICE_SIZE); + int processingTime = head.getProcess() + .process(time, SLICE_SIZE); prevPid = head.getProcess().getPid(); if (head.getProcess().finished()) { processed.add(queue.remove(0).getProcess()); diff --git a/Report.md b/Report.md @@ -10,5 +10,60 @@ linkcolor: blue The Narrow Round Robin scheduling algorithm was the best performing for the first data file, and First Come First Served performed the worst. Both Round -Robin and Feedback performed equally in this case. All of the rankings for best -to worst are notably +Robin and Feedback performed equally in this case. The performance of these +algorithms is maximised by the reduction of time spent of processes for longer +amounts of times spent on processes in the case where all the processes arrive +at the same time. This may be observed with First Come First Served perfoming +the worst, since it sequentially processes each whole process. Next, Round +Robin and Feedback which perform equally as they both have a constant slice +size, yet they perform better than FCFS as involve more switching between +processes which allows smaller processes to wait less before completing. +Finally Narrow Round Robin is the best performing as it reduces the slice size +for each time it processes a process, this makes it so that less expensive +processes have to wait for less time before their turnaround. + +# Datafile 2 + +In this data file, the processes each come in a differing times, this made the +scheduling algorithms in order from worst performing to best performing +Narrow Round Robin, Round Robin, First Come First Served, and Feedback. Both +Round Robins performed badly in this case as they switch through processes on +a queue structure with no priority system, this means the that the first +process will process for a slice, other processes get added in, then when the +slice is finished, the first will have to wait through the slices of the added +processes before continuing. Narrowing makes this worse by making so that first +process has even less processing time before switching. First Come First Served +performs a bit better as it completes each whole process when it is dequeued. +Feedback Perfroms the best in this case due to the priority system, this means +that even though there are slices, each process is placed on a tier that +marks the immediacy of the need to process them, thus making for less waiting +times. + +# General Observation + +From these observations, it can be concluded that the Feedback scheduler is on +average the best performing of the scheduling algorithms, and that whether the +Round Robin schedulers or the First Come First Served schedulers perform better +then one another is dependant on the timing of how the processes arrive. + +The Feedback scheduler performs best on average due to its combination of +slicing processing and the priority system. The slicing of processing makes it +so that a process does not take up the processor for too long of periods of +time, and thus allows shorter processes to complete without having to wait too +long for those longer ones. The priority system makes it so that the a service +does not have to wait to long to start processing, this allows shorter +processes to be finished quite quickly, while longer ones may have spend a bit +of time waiting, although not too long as the shorter processes will be +finished and eliminated from the queue quite quickly. + +The First Come First Served scheduler performed better when processes arrive at +different times as it processes those sequentially in order of arrival, this +reduces waiting time in a lot of cases. + +The Round Robin schedulers performed best when all of the processes arrived +at the same time. This is due to the slicing of processing, which means that +smaller processes do not have to wait through some of the bigger ones to +complete processing before having a chance to process. The narrowing variation +of the scheduler tended to perform better as it tended to give the processes +more of a chance to do some processing in a similar way to that of priority +system. diff --git a/Scheduler.java b/Scheduler.java @@ -6,7 +6,7 @@ import java.util.ArrayList; * * Interface for the scheduler classes * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */ diff --git a/SortbyPid.java b/SortbyPid.java @@ -4,7 +4,7 @@ import java.util.Comparator; * <h1>SortbyPid - Comp2240A1</h1> * Sort the processes by their id * - * @author Cody Lewis + * @author Cody Lewis (c3283349) * @version 1 * @since 2019-08-17 */