Preview

java

Satisfactory Essays
Open Document
Open Document
312 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
java
AllocationStrategy.java

import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Queue;

/* implement this class for all three strategies */

public abstract class AllocationStrategy { protected List Jobs; protected ArrayList Queue; public AllocationStrategy(List jobs) { super(); Jobs = jobs; } public abstract void run(); // update current job by 1 tick // check if the job queue might need to be changed. // check for jobs to add to the queue
}

FirstComeFirstServed.java

import java.util.ArrayList; import java.util.List;

public class FirstComeFirstServed extends AllocationStrategy {

int temp; int proceessArrivalTime; int waitingTime; double avgWaitingTime; double avgTurnAroundTime; public FirstComeFirstServed(List jobs) { super(jobs); }

@Override public void run() {

}

public void run(List jobList) { int count = 0; System.out.println("============================================ "); System.out.println("Process ID | Turnaround time | Waiting time "); System.out.println("============================================ "); for(Job job:jobList){ if(count==0){ job.processArrivalTime = job.getArrivalTime(); job.ProcessCompletionTime = job.getArrivalTime()+job.getCpuTime(); }else{ job.processArrivalTime = temp-job.getArrivalTime(); job.ProcessCompletionTime = temp+job.getCpuTime(); } temp = job.ProcessCompletionTime; job.turnAroundTime = temp-job.getArrivalTime(); job.waitingTime = job.turnAroundTime-job.getCpuTime(); count++; avgWaitingTime = avgWaitingTime+job.waitingTime; avgTurnAroundTime = avgTurnAroundTime+job.turnAroundTime; System.out.println(" "+job.getProcessId()+" | "+" "+job.turnAroundTime+" | "+" "+job.waitingTime+" "); System.out.println("----------------------------------------"); }

You May Also Find These Documents Helpful

  • Satisfactory Essays

    PT1420 Unit 8 Lab 8

    • 365 Words
    • 2 Pages

    Step 3: Write a for loop that will print 60 minutes to the screen. Complete the missing…

    • 365 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Kristen's Cookies

    • 491 Words
    • 2 Pages

    In this process the Step 3 & 4 have the longest processing time of 10 minutes which means this is the bottleneck in the process. We know that the bottleneck determines the maximum output of the process. The bottleneck time is also referred to as the cycle time.…

    • 491 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Hrm/531 Week 3 Quiz

    • 1774 Words
    • 8 Pages

    of 2.5 minutes. What is the probability that the service time is between 2 and 4…

    • 1774 Words
    • 8 Pages
    Good Essays
  • Satisfactory Essays

    Solution: Sue can paint of the garage in 1 hour. Joe can paint of the garage in one hour. We don’t know how long it will take them working together, so we let x = the number of hours it takes them to paint the kitchen working together. Below is a table that relates the data from our problem. We are using the concept that (rate)(time) = fraction of the task done.…

    • 338 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Java

    • 5076 Words
    • 21 Pages

    Explanation: B) Programs are classified as software to differentiate them from the mechanisms of the computer (hardware). Storage and the processor are two forms of hardware while input is the information that the program processes.…

    • 5076 Words
    • 21 Pages
    Good Essays
  • Powerful Essays

    Little Field

    • 1525 Words
    • 7 Pages

    We assumed that the job arrival rate and the job processing rate followed a Memory less pattern and we used the PK formula to calculate the waiting times for the different queues. We made the following assumptions:…

    • 1525 Words
    • 7 Pages
    Powerful Essays
  • Satisfactory Essays

    Time Elapsed | 3 hours, 39 minutes out of 4 hours and 30 minutes. |…

    • 1577 Words
    • 7 Pages
    Satisfactory Essays
  • Good Essays

    Java

    • 490 Words
    • 3 Pages

    Write a Java program to demonstrate using bitmaps and bitwise operators to sort and remove duplicates from a file of random phone numbers. Do not confuse the term bitmap used for compressing data into smaller spaces with the bitmap that has come to mean a graphic image.…

    • 490 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Procurement

    • 2706 Words
    • 11 Pages

    Pang X, Wu Z, Li S, 2005, ‘job shop scheduling in real-time cases’, Original Article, volume 26, issue 5, pp 870-875…

    • 2706 Words
    • 11 Pages
    Powerful Essays
  • Powerful Essays

    Communication

    • 2426 Words
    • 10 Pages

    * Explain the role of effective communication and interpersonal interaction in health and social care context:…

    • 2426 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    Scope Statement

    • 463 Words
    • 2 Pages

    The time required to complete execution phase is 147 because the number of tasks to…

    • 463 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Bca Cs-63

    • 1608 Words
    • 7 Pages

    There are seven questions in this Assignment. Answer all the questions. You may use illustrations and diagrams to enhance explanation.…

    • 1608 Words
    • 7 Pages
    Powerful Essays
  • Powerful Essays

    Stonehaven Case Analysis

    • 1913 Words
    • 8 Pages

    Manufacturing Lead Time (MLT) = Since the machines work simultaneously, the MLT is 41 min/batch.…

    • 1913 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    Econometrics: Exercises

    • 1186 Words
    • 11 Pages

    Let totwrk_hr be the total hours worked during the week. Without using the computer, what…

    • 1186 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    SINGLE/MULTIPLE SERVER QUEUE (Model 1 & 3) lambda/mu 1.333333333 s-1 1 Arrival rate 20 lambda/(mu*s) 0.666666667 Service rate 15 2.666666667 s factorial = 2 Number of servers 2 P(0) = 0.2 0.533333333 2 Utilization 66.67% n Pn 1 2 P(0), probability that the system is empty 0.2000 0 1 0.2 0.2 1 2 Lq, expected queue length 1.0667 1 1.333333333 0.266666667 0.266666667 1 2 Ls, expected number in system 2.4000 2 0 0.177777778 0 1 2 Wq, expected time in queue 0.0533 3 0 0.118518519 0 1 2 Ws, expected total time in system 0.1200 4 0 0.079012346 0…

    • 397 Words
    • 2 Pages
    Satisfactory Essays

Related Topics