it related to java programming

 have two classes that need to be implemented 

  1. edfscheduler
  2. processSet'

these two classes need to be implemented. 

Get Help With a similar task to - it related to java programming

Login to view and/or buy answers.. or post an answer
Additional Instructions:

SWE30001 Semester 2, 2020 Dr. Markus Lumpe 1 Swinburne University of Technology Faculty of Science, Engineering and Technology ASSIGNMENT COVER SHEET Subject Code: SWE30001 Subject Title: Real-time Programming Assignment number and title: 3, Deterministic Scheduling Due date: October 8, 2020, 16:30 Lecturer: Dr. Markus Lumpe Your name: Your student id: Check Tutorial Thurs 16:30 Thurs 17:30 Marker's comments: Problem Marks Obtained Class EDFScheduler 72 Class ProcessSet 93 Total 165 Extension certification: This assignment has been given an extension and is now due on Signature of Convener: SWE30001 Semester 2, 2020 Dr. Markus Lumpe 2 Problem Set 3: Deterministic Scheduling Consider a system comprising the periodic processes T1 = (19, 80, 80), T2 = (44, 175, 175), T3 = (38, 115, 115), and T4 = (8, 65, 65). All time unit are in milliseconds. The aim of this problem set is to implement system simulation that uses Earliest Deadline First (EDF) as priority-based scheduling mechanism. The application is a simple Java Console program that runs continuously and schedules the processes T1, T2, T3, and T4 according to EDF and protocols whether the processes have met their respective deadlines and how much time is available before the next activation. Below there is a small trace of a sample run: RMA not possible Running with EDF: U = 0.942440 T4 finished on time (5 ms to next activation) T1 finished on time (6 ms to next activation) T4 finished on time (56 ms to next activation) T3 finished on time (23 ms to next activation) T2 finished on time (75 ms to next activation) T1 finished on time (59 ms to next activation) T4 finished on time (57 ms to next activation) T3 finished on time (77 ms to next activation) T1 finished on time (61 ms to next activation) T4 finished on time (57 ms to next activation) T2 finished on time (131 ms to next activation) T1 finished on time (60 ms to next activation) T3 finished on time (76 ms to next activation) T4 finished on time (57 ms to next activation) T4 finished on time (57 ms to next activation) T1 finished on time (61 ms to next activation) T3 finished on time (77 ms to next activation) T2 finished on time (129 ms to next activation) T4 finished on time (57 ms to next activation) T1 finished on time (61 ms to next activation) T4 finished on time (57 ms to next activation) T3 finished on time (77 ms to next activation) T1 finished on time (61 ms to next activation) T4 finished on time (57 ms to next activation) … The program first tests if the process set can be scheduled using RMA. It is not RMA schedulable. Next, it tests if the process set is EDF schedulable, which it is. So, the program commences the EDF scheduler. Please note that a first run of the program can exhibit a few deadline misses (due to the Java class loader requiring more time initially). Subsequent runs should rarely result in deadline misses. A corresponding Java software solution requires several components: an abstraction to represent periodic processes, an abstraction to represent process sets, and an abstraction to represent the EDF scheduler. To simplify the task, the implementation for periodic processes is provided. In addition, you are given a Processor class and an abstract class Scheduler. The former is used to add a single CPU to the simulation. All processes and the scheduler run on this CPU. In other words, the CPU is a shared resource that needs to be properly acquired and access to it must be synchronized. The Scheduler class defines the methods that each scheduler must implement. Concrete implementations of schedulers must implement all abstract methods. Note, the period processes are scheduler agnostic. That is, a process has access to a scheduler, but its type (i.e., whether it is an EDF scheduler or not) is unimportant. SWE30001 Semester 2, 2020 Dr. Markus Lumpe 3 The main function of the simulation creates a process set, computes the utilization, and activates the process set using an EDF scheduler: import edf.EDFScheduler; import scheduling.Process; import scheduling.ProcessSet; import scheduling.Processor; public class Main { private ProcessSet fSet; public Main() { fSet = new ProcessSet(); fSet.add( new Process( "T1", 19, 80, 80 ) ); fSet.add( new Process( "T2", 44, 175, 175 ) ); fSet.add( new Process( "T3", 38, 115, 115 ) ); fSet.add( new Process( "T4", 8, 65, 65 ) ); } public void execute() { if ( fSet.meetLiuAndLayland() ) { System.out.println( "RMA by Liu&Layland" ); } else { if ( fSet.meetCriticalInstant() ) { System.out.println( "RMA by Critical Instant" ); } else { System.out.println( "RMA not possible" ); } } double lUtilization = fSet.computeEDFUtilization(); if ( lUtilization <= 1.0 ) { System.out.println( String.format( "Running with EDF: U = %g", lUtilization ) ); fSet.activate( new EDFScheduler( new Processor() ) ); } else { System.out.println( "Process set exceeds permissible utilization." ); } } public static void main( String[] args ) { (new Main()).execute(); } } SWE30001 Semester 2, 2020 Dr. Markus Lumpe 4 The class Processor just has one method. It is not used in the application, but it can be invoked for debug purposes in the run method of class Process. package scheduling; public class Processor { public synchronized void running( Process aProcess ) { System.out.println( String.format( "Running %s", aProcess.getName() ) ); } } The abstract class Scheduler provides the super class for all concrete schedulers package scheduling; import java.util.ArrayList; public abstract class Scheduler { private Processor fCPU; // the CPU instance public Processor getCPU() { return fCPU; } public Scheduler( Processor aCPU ) { fCPU = aCPU; fProcessQueue = new ArrayList<Process>(); } protected ArrayList<Process> fProcessQueue; // a protected process queue public abstract void arrived( Process aProcess ); // add process to queue public abstract void finished( Process aProcess ); // remove process from queue } A concrete scheduler has to implement the methods arrived and finished. A scheduler maintains two instance variables: fCPU and fProcessQueue. The instance variable fCPU represents the single CPU in the system. Programmatically, fCPU serves as shared object, process synchronize on. Specifically, the methods arrived and finished must secure exclusive access to fCPU for the whole time they are being executed. The scheduler “occupies” the CPU. The instance variable fProcessQueue implements the priority queue for scheduling. The class java.util.ArrayList provides the necessary implementation type. Only the first process in fProcessQueue is currently running on the CPU. Once this process has finished, it is being removed from fProcessQueue and the next available process is scheduled. When processes arrive (i.e., they execute again), the scheduler must insert them into fProcessQueue and sort fProcessQueue according to the EDF scheduling policy. The first process fProcessQueue in must be scheduled if it is not already running and the running process must be preempted if it is not first in the queue. Processes have two methods setRunning and setSuspended to schedule them and to preempt them. In addition, processes have the getNextDeadline method that return the exact deadline of a process with respect to the current system time in milliseconds. Processes that are preempted, wait for the CPU. Use notifyAll to wake them up. Implement a public class EDFScheduler that extends Scheduler. EDFScheduler requires a constructor. SWE30001 Semester 2, 2020 Dr. Markus Lumpe 5 To schedule processes, we use an instance of class ProcessSet. package scheduling; import java.util.ArrayList; public class ProcessSet { // a list of processes private ArrayList<Process> fProcesses; // constructor: initialize instance variables public ProcessSet() { ... } // add process to list if it is not already in the list public void add( Process aProcess ) { ... } // remove process from list if it is in the list public void remove( PeriodicProcess aProcess ) { ... } // activate all processes in list (start the process on scheduler aScheduler) public void activate( Scheduler aScheduler ) { ... } // terminate all processes in list (stop process) public void terminate() { ... } // test Lie&Layland criterion public boolean meetLiuAndLayland() { ... } // test critical instant of Pm public boolean meetCriticalInstant() { ... } // return utilization public double computeUtilization() { ... } // return the EDF utilization (use smaller of period and deadline) public double computeEDFUtilization() { ... } } Implement a public class ProcessSet. SWE30001 Semester 2, 2020 Dr. Markus Lumpe 6 Download class PeriodicProcess and Process from Canvas. Study its implementation. It has been tested and it works within the given specification. Class Process simulates a periodic real-time process. Its execute method mimics a computation with length computation time in milliseconds. It does so by advancing every one millisecond with intermitted waits so that other processes may be able to run and the scheduler can operate. If a process is not in state RUNNING it has to wait, that is, the scheduler has preempted this process. Wait is always on the CPU. The execute method of a Process is invoked in the run method, every time a new period starts. Intermittently, Process instances sleeps (using wait). Class PeriodicProcess: package scheduling; public abstract class PeriodicProcess { private String fName; private long fComputationTime; private long fPeriod; private long fDeadline; public String getName() { return fName; } public long getComputationTime() { return fComputationTime; } public long getPeriod() { return fPeriod; } public long getDeadline() { return fDeadline; } public PeriodicProcess( String aName, long aComputationTime, long aPeriod, long aDeadline ) { fName = aName; fComputationTime = aComputationTime; fPeriod = aPeriod; fDeadline = aDeadline; } } SWE30001 Semester 2, 2020 Dr. Markus Lumpe 7 Class Process: package scheduling; public class Process extends PeriodicProcess implements Runnable { private enum ProcessStates { UNASSIGNED, READY, RUNNING, SUSPENDED } private ProcessStates fState; private Scheduler fScheduler; private Thread fThread; public Process( String aName, long aComputationTime, long aPeriod, long aDeadline ) { super( aName, aComputationTime, aPeriod, aDeadline ); fState = ProcessStates.UNASSIGNED; fScheduler = null; fThread = new Thread( this, aName ); } public void start( Scheduler aScheduler ) { if ( fThread != null ) { fScheduler = aScheduler; fThread.start(); } } public void stop() { if ( fThread != null ) { fThread.interrupt(); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append( '[' ); sb.append( getName() ); sb.append( ','); sb.append( fState ); sb.append( ','); sb.append( fNextDeadline % 1000000 ); sb.append( ']' ); return sb.toString(); } private long fNextDeadline; public synchronized long getNextDeadline() { return fNextDeadline; } SWE30001 Semester 2, 2020 Dr. Markus Lumpe 8 public synchronized void setRunning() { fState = ProcessStates.RUNNING; } public synchronized void setSuspended() { fState = ProcessStates.SUSPENDED; } private Processor fCPU; private void execute() throws InterruptedException { // set actual deadline for current run synchronized (this) { fNextDeadline = System.currentTimeMillis() + getDeadline(); } long lComputeTime = 0; fState = ProcessStates.READY; fScheduler.arrived( this ); // emulate process computation (simplified, prone to overflows) while ( lComputeTime < getComputationTime() ) { synchronized (fCPU) { if ( fState == ProcessStates.RUNNING ) { // compute real time spent in suspension long lStartLoop = System.currentTimeMillis(); // elapse one time unit (may be longer ) // MacOS: 1-2 ms // Windows: 12-15 ms fCPU.wait( 1 ); if ( fState == ProcessStates.RUNNING ) { lComputeTime += (System.currentTimeMillis() - lStartLoop); } } else { fCPU.wait(); // process is suspended } // must be in critical section fScheduler.finished( this ); } } fState = ProcessStates.READY; } public void run() { // process must have assigned a scheduler if ( fScheduler != null ) { fCPU = fScheduler.getCPU(); try { // process loop while ( fThread != null ) { execute(); // execute process SWE30001 Semester 2, 2020 Dr. Markus Lumpe 9 long lWaitTime = fNextDeadline - System.currentTimeMillis(); if ( lWaitTime > 0 ) { System.out.println( String.format( "%s finished on time (%d ms to next activation)", getName(), lWaitTime ) ); synchronized (this) { wait( lWaitTime ); // wait n time units before next activation } } else { System.out.println( String.format( "OVERRUN: %s missed deadline by %d ms", getName(), -lWaitTime ) ); } } } catch (InterruptedException e) {} } fThread = null; } } Deadline: Thursday, October 8, 2020, 16:30. Submission procedure: PDF of printed classes ProcessSet and EDFScheduler. Your name: Your student id: Thurs 1630Check Tutorial: Thurs 1730Check Tutorial:

Related Questions

Similar orders to it related to java programming
7
Views
0
Answers
Java Customer Program
Problem 1: Customer Max has opened his own pet supply store so he can help himself to treats and toys whenever he wishes. In order to encourage customers to shop at his store more, he is implementing a customer loyalty program. For every $100 spent, the c...
11
Views
0
Answers
Literature Review for Smart Case for tracking monitoring and tracing packages being delivered
They're three attachments below one being the handbook to help guidance during this progress another being the first proposal of the project and then the assignment that needs completing, the Literature review....
15
Views
0
Answers
c++ lab 1 intro lab
P ROBLEM STATEMENT: A review and extension of cs132: sort a file with 120 records. However, due to memory restrictions only 20 records may be placed into memory. You are to implement a “quasi” external sort CODE/DIRECTIONS: For the sake of si...
19
Views
0
Answers
Cryptography Assignment C
1. Write two programs that use some of the build-in Cryptographic APIs a. Write one C program that uses Symmetric-Key algorithm b. Write one C program that used Asymmetric-key algorithm c. Use C programming language to write your code d. Make sure tha...