Question: Hello below you will see the code I have created that provides this functionality: Code ThreadIO.java :- ------------------------- /** * * @author This thread perform

Hello below you will see the code I have created that provides this functionality:

Hello below you will see the code I have created that provides

Code

ThreadIO.java :-

-------------------------

/** * * @author This thread perform the IO operation * */ public class ThreadIO extends Thread { //Variable for Start and Stop time... /** * startTime When called Thread.Start * startExecutionTime when run method started execution (get the CPU) * stopTime is when run() method completed * waitTime is Time Difference between startTime,startExecutionTime + wait for IO */ long startTime,stopTime,runningTime , waitTime , startExecutionTime; @Override public synchronized void start() { // set Start time to current System time startTime = System.currentTimeMillis(); // TODO Auto-generated method stub super.start(); } @Override // define the body which need to be executed by the thread public void run() { // set Start Execution time to current System time startExecutionTime = System.currentTimeMillis(); for (int i = 0; i

}

ComputationThread.java

------------------------------------------

public class ComputationThread extends Thread {

int a = 3; int b = 6; //Variable for Start and Stop time... /** * startTime When called Thread.Start * startExecutionTime when run method started execution (get the CPU) * stopTime is when run() method completed * waitTime is Time Difference between startTime,startExecutionTime */ long startTime,stopTime,runningTime , waitTime , startExecutionTime; @Override public synchronized void start() { // set Start time to current System time startTime = System.currentTimeMillis(); // TODO Auto-generated method stub super.start(); }

@Override // define the body which need to be executed by the thread public void run() { // set Start Execution time to current System time startExecutionTime = System.currentTimeMillis(); //Computation Thread should not do any I/O like System.out.println so remove for (int i = 0; i

ControllerThread.java

------------------------------------------

/** * * @author Controls all the threads * */ public class ControllerThread {

// number of objects of ThreadIo and computationThread class to be created static final int NUMBER_OF_THREADS = 5; // create an array of 5 objects of each ThreadIo and computationThread // class ThreadIO IOobjects[] = new ThreadIO[NUMBER_OF_THREADS]; ComputationThread computationThread[] = new ComputationThread[NUMBER_OF_THREADS]; //Method to initialize the threads public void initilaizeThread(){ for (int i = 0; i

} } //Method to start all IO threads public void startIOThreads(){ for (int j = 0; j

long scheduleStartTime = 0; long scheduleEndTime = 0; ControllerThread controller = new ControllerThread(); controller.initilaizeThread(); // record the start schedule Time scheduleStartTime = System.currentTimeMillis(); //Re Arrange of Execution of IO/Computation threads //If you don't want to start certain type of Thread then comment controller.startComputationThreads(); controller.startIOThreads();

// record the end time of the schedule scheduleEndTime = System.currentTimeMillis(); //Print Results controller.printResults(); System.out.println("******************************************************"); System.out.println("Computation time of Schedule all the Threads"); System.out.println("******************************************************"); System.out.println("Time Taken to schedule and run all the threads: "+(scheduleEndTime -scheduleStartTime)+ " milliseconds"); }

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What I need done is: Altering the code above where you have added one more worker thread, there should be already 5 in the code above. And provide code that runs the processes differently and keeps timing them like the above code does. The scheduling system presented in the code above is FCFS. The code I need is for if you scheduled the tasks First-come, and Shortest job route. If you can do The round robin method using the following methods(Suspend and resume) that is a plus! All i need in this case is the code maniuplated to do the other times of scheduling so I can get the time it takes for the processes to finish. Thanks.

1. Take the project you wrote in the homework last week and do a FCFS scheduler with 5 lo bound threads (1 class) and 5 processor bound threads (another class). a) The IO bound class will be a thread class that runs an IO intensive operation. You can write to the system out a number of times (ie 1000) or do something like read and write a file. b) he processor bound class will be a thread class that runs a computationally intensive operation. You can perform some math computation a number of times No lo in the loop. c) Create a controller class that implements an FCFS schedule and instantiates 5 objects of each class and runs each object. 2) Take the start and stop time for each thread and print out the time it takes to run. 3) Take the start and stop time to schedule and run all the threads and print out the time to run. 1. Take the project you wrote in the homework last week and do a FCFS scheduler with 5 lo bound threads (1 class) and 5 processor bound threads (another class). a) The IO bound class will be a thread class that runs an IO intensive operation. You can write to the system out a number of times (ie 1000) or do something like read and write a file. b) he processor bound class will be a thread class that runs a computationally intensive operation. You can perform some math computation a number of times No lo in the loop. c) Create a controller class that implements an FCFS schedule and instantiates 5 objects of each class and runs each object. 2) Take the start and stop time for each thread and print out the time it takes to run. 3) Take the start and stop time to schedule and run all the threads and print out the time to run

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!