Question
Write a java program that represents a preemptive low priority scheduler, and calculate the waiting time...
Write a java program that represents a preemptive low priority scheduler, and calculate the waiting time for each process. Low priority means that the low the number the higher the priority. Also assume that processes can arrive at different times. Hint: Use a priority queue.
Answers
In this answer i solve it in non-premative approch....
I learn lot of things for that...
Language Java 6 Run Debug Stop Share Save {}Beautify Main.java 1 import java.util.Scanner; 2 public class Main 3-{ public static void main(Strin [] args) { int i, j,pos; int[] arivaltime, priority, bursttime, waitingTime; System.out.println("enter the number of process"); Scanner in=new Scanner(System.in); int a= in.nextInt(); arivaltime = new int[a]; priority= new int[a]; waitingTime= new int[a]; System.out.println("enter the arivalTime for each process"); for (i=0;i<a;i++) { arivaltime[i]= in.nextInt(); System.out.println("enter the priority for the each process"); NNNUD for(i=0;i<a;i++) { priority[i]= in.nextInt(); bursttime= new int[a]; System.out.println("enter the bursttime for the each process"); for (i=0;i<a; i++){ bursttime[i]=in.nextInt(); intilococessName. inputRun Debug Stop Share Save } Beautify Language Java Main.java 38 39 int[] processName; processName=new int[a]; for(i=1;i<a+1;i++){ processName[i-1]=i; // main logic start from here........ int time; for(i=0;i<a;i++) pos=i; for(j=i+1;i<a; i++) { if(priority[j]>priority[pos]){ pos=j; time priority[i]; priority[i]=priority[pos]; priority[pos] =time; time=bursttime[i]; bursttime[i]=bursttime [pos]; bursttime[pos]=time; waitingTime[0]=0; System.out.println("procsstburst time t priority \t waitingTime\n"); for(i=0;i<a ;i++) waitingTime[i]=0; for(j=0; j<i; j++){ waitingTime[i] waitingTime[i]+bursttime[j]; System.out.println(i+1+' t'+bursttime[i]+'\t'+priority[i]+'\t'+waitingTime[i]+"\n");
Similar Solved Questions
1 answers
Find the standard deviation for the given data
Find the standard deviation for the given data. Round your answer to one more decimal place than the original data. {2,5,47,11,13,48,39,36}A). 18 B). 324.9 C).25.1 D). 24.5I got 19.3 but it is not one of the multiple choices, am I doing it wrong?...
1 answers
Construct a context-free grammar for the language L={ab'ab'an> 1}.
Construct a context-free grammar for the language L={ab'ab'an> 1}....
1 answers
LEARN MORE REMARKS Because the density of gold Is 1.93 x 104 kg/m", the crown is...
LEARN MORE REMARKS Because the density of gold Is 1.93 x 104 kg/m", the crown is elther hollow, made of an alloy, or both. Despite the mathematical complexity, it is certainly conceivable that this was the method that occurred to Archimedes. Conceptually, it's a matter of realizing (or guess...
1 answers
Question 3, chap 123, sect 5. part 1 of 1 10 points Consider the three charges...
Question 3, chap 123, sect 5. part 1 of 1 10 points Consider the three charges below. The value of Coulomb's constant is 8.9875 x 109 N . m2/c2 90° 8 HC What is the magnitude of the electrostatic force | Fll on the top charge? Answer in units ofN...
1 answers
Please help me ,, don't use handwriting .. i need unique answer don't copy and paste...
please help me ,, don't use handwriting .. i need unique answer don't copy and paste 1-What is the difference between sunblock and sunscreen cream? 2-What is SPF? 3-Which is better SPF30+ or 50+?...
1 answers
How many polypeptide chains are shown in the quarternary structure of the protein ? What types...
How many polypeptide chains are shown in the quarternary structure of the protein ? What types of bonds and interactions hold the quaternary structure in place Mouetelh Structure (Part B) Tertiary Structure ーCH CH-SS CH CH NH -CH2 CH, CH CH Quaternary Structure CH CH Three polypeptide chai...
1 answers
U Question 8 1 pts What is the total resistance of the circuit shown? Assume the...
U Question 8 1 pts What is the total resistance of the circuit shown? Assume the 9V battery is ideal and has no internal resistance. 40 9V 622 ww $20 6.75 12 n 30 0.33 Question 9 1 pts In the previous question, what is the current flowing through the 6 resistor? 20A 3.0A 0.5A 15 A...
1 answers
Moist air at 20° c, 1 atm, and 43% relative humidity and a volumetric flow rate...
Moist air at 20° c, 1 atm, and 43% relative humidity and a volumetric flow rate of 900 m/hrs. enters a control volume at steady state and flow along a surface maintained at 65 C, through which heat transfer occurs. Liquid water at 20" C is injected at a rate of 5 kg/hr and evaporates into fl...
1 answers
Create a Psychology stats question : step 1: make a frequency or grouped frequency distribution table,...
Create a Psychology stats question : step 1: make a frequency or grouped frequency distribution table, and do an interpolation to find some percentile. Part Two must require finding the Z-score and probability for a sample mean. Part Three must require doing some type of t-test and reporting the res...
1 answers
MATLAB HELP 3. Consider the equation y′ = y2 − 3x, where y(0) = 1. USE THE EULER AND RUNGE-KUTTA APPROXIMATION SCRIPTS...
MATLAB HELP 3. Consider the equation y′ = y2 − 3x, where y(0) = 1. USE THE EULER AND RUNGE-KUTTA APPROXIMATION SCRIPTS PROVIDED IN THE PICTURES a. Use a Euler approximation with a step size of 0.25 to approximate y(2). b. Use a Runge-Kutta approximation with a step size of 0....
1 answers
I NEED URGENT HELP AS THE ASSIGNMENT IS SUE IN HALF AN HOUR, PLEASE AND THANK...
I NEED URGENT HELP AS THE ASSIGNMENT IS SUE IN HALF AN HOUR, PLEASE AND THANK YOU!! Question 2 of 2 - 10 E View Policies Current Attempt in Progress Amachine that produces cellphone components is purchased on January 1, 2020, for $182,000. It is expected to have a useful life of four years and a r...
1 answers
Problem 1 An inverted pendulum driven by a d-c motor is governed by the following differential...
Problem 1 An inverted pendulum driven by a d-c motor is governed by the following differential and algcbraic equa tions: (a) Determine the transfer function of the process. (b) It is proposed to control the process using "proportional control": where yr is a constant reference value. Determi...
1 answers
Please with no plagiarism 10B: Write your team's reaction to this statement from this week's reading:...
Please with no plagiarism 10B: Write your team's reaction to this statement from this week's reading: “Technology is not neutral,” said Professor Sahami, who formerly worked at Google as a senior research scientist. “The choices that get made in building technology then ...
1 answers
Let W = Span {(1, 2, -2,-4),(-1,3,1,2), (2,1,3,6), (0,2,0,0)} be a subspace. Which vector extends the...
Let W = Span {(1, 2, -2,-4),(-1,3,1,2), (2,1,3,6), (0,2,0,0)} be a subspace. Which vector extends the basis of W to the basis of the whole R4 (0,0,1,0) (1,1,0,0) (0,0,0,1) (1,1,1,0) (0,1,0,0) (1,0,1,0)...