1, Request
- This paper expounds the process from submission to execution of multiple jobs, and explains the concept, differences and relationship of three-level scheduling;
- The ideas, characteristics, advantages and disadvantages of FCFS, SJF/SPF, HRRN, RR and multi-level feedback queue scheduling algorithms are described;
- The algorithm realizes the calculation of completion time, turnaround time, weighted turnaround time, average turnaround time and average weighted turnaround time.
- This paper expounds the idea and idea of simulating the programming of process scheduling algorithm, and draws the general flow chart and each branch flow chart; The implementation process of key data structures, classes, objects, methods and interfaces are described.
two , Experimental principle
This paper expounds the process from submission to execution of multiple jobs, and explains the concept, differences and relationship of three-level scheduling;
The ideas, characteristics, advantages and disadvantages of FCFS, SJF/SPF, HRRN, RR and multi-level feedback queue scheduling algorithms are described;
3, Experimental thought
Time slice rotation
The algorithm realizes the calculation of completion time, turnaround time, weighted turnaround time, average turnaround time and average weighted turnaround time. This paper expounds the idea and idea of simulating the programming of process scheduling algorithm, and draws the general flow chart and each branch flow chart; The implementation process of key data structures, classes, objects, methods and interfaces are described.
Define a process. Its attributes include process name, process start time, process run time, and whether the process is completed (the initial value is false)
Then define the test class to realize process scheduling, and the test class mainly realizes the logic in the diagram.
4, Experimental procedure
package diaodu; import java.util.ArrayList; import java.util.Scanner; public class Text { public static void main(String[] args) { int h[],c=0; double p=0,t=0; System.out.println("Enter the number of processes:"); Scanner scan=new Scanner(System.in); int a=scan.nextInt(); System.out.println("Please enter the name, arrival time and running time of the process"); ArrayList<RR> z=new ArrayList<RR>(); RR[] b=new RR[a]; h=new int[a]; for(int i=0;i<a;i++) { b[i]=new RR(scan.next(),scan.nextInt(),scan.nextInt(),scan.nextBoolean()); h[i]=b[i].run; } int i=0,j=0; RR l = null; //The time slice is 2 label:while(true) { if(b[i].start<=j) { z.add(b[i]); if(l!=null) z.add(l); if(!z.isEmpty()) { RR g=z.remove(0); if(g.run>2) { System.out.println("-------------------"); System.out.println(g.name+"Run 2 time slices"); g.run-=2; j+=2; l=g; i++; }else if(g.run<=2&&g.run!=0){ System.out.println("-------------------"); System.out.printf(g.name+"function%d Time slice\n",g.run); j+=g.run; g.run=0; l=g; i++; }} }else { if(!z.isEmpty()) { RR g=z.remove(0); if(g.run>2) { System.out.println("-------------------"); System.out.println(g.name+"Run two time slices"); g.run-=2; j+=2; z.add(g); }else { System.out.println("-------------------"); System.out.printf(g.name+"function%d Time slice\n",g.run); j+=g.run; g.run=0; z.add(g); } } } if(i>=a)i=0; for(int k=0;k<a;k++) { if(b[k].run==0&&b[k].over!=true) { b[k].over=true; c++; System.out.println("---------------------------------------"); System.out.println(b[k].name+"Completed on:"+j+"Turnaround time:"+(j-b[k].start)+"Weighted turnaround time:"+(j-b[k].start+0.0)/h[k]); p=p+(j-b[k].start); t=t+(j-b[k].start)/h[k]; } } if(c==a)break label; } System.out.println("Average turnaround time:"+p/a); System.out.println("Average weighted turnaround time:"+t/a); } } package diaodu; public class RR{ String name; int start; int run; boolean over; public RR(String name,int start,int run,boolean over) { this.name=name; this.start=start; this.run=run; this.over=over; } }
5, Experimental results and analysis
Output results include: completion time, turnover time, weighted turnover time, average turnover time, average weighted turnover time