Experiment two, job scheduling simulation program
First, Experimental Purpose
1) Deepen the understanding of the job scheduling algorithm;
(2) Training in program design.
two . Experimental requirements
A simulation program that writes one or more job schedules in a high-level language.
Job scheduler for single-channel batch processing systems. When the job is put into operation, it occupies all the resources of the computer until the job is completed, so it is not necessary to schedule the job to consider whether the resources it needs are met, the time it runs, and so on.
Third, test methods, procedures and results
- 1. source program name:work1.0.cpp
executable program Name: work1.0. EXE
- 2. principle Analysis and Flowchart
Storage structure: struct-body array
Principle analysis: According to the requirements of the experiment, the program needs to read, input, insert, delete and so on, after selecting the scheduling method, then output the scheduling results.
Experimental process: Read the experimental requirements, first planning program structure to divide the program into multiple parts, and then improve the various parts, and finally the various program sections together à debugging
Program running process: According to the prompts to enter the appropriate number to select the function.
- 3. Main procedural paragraphs and their explanations:
Structure:
1 structmsg2 {3 Charname[Ten];4 intStartTime;//Arrival Time5 intRunTime;//Service Hours6 intEndTime;//Completion Time7 intDotime;//Scheduling Time8 floatTurnaroundtime;//Turnaround Time9 floatWeightedturnaroundtime;//turnaround time with weightTen};
Main function:
1 voidMain () {2 3Msg user[ -];4 intn=0;5 floataveragetime[2];//use arrays to store average turnaround time (subscript 0) and weighted average turnaround time (subscript 1)6 intSelect1;7 intSelect2=1;;8printf"C Program Simulation----of----job scheduling algorithm");9 Ten while(1) One { Aprintf"\n\n\t---menu---\ n"); -printf"\t1. Read the job details file \ n"); -printf"\t2. Entering job information \ n"); theprintf"\t3. Inserting jobs \ n"); -printf"\t4. deleting jobs \ n"); -printf"\t5. Select the scheduling algorithm (default first-to-first service algorithm) \ n"); -printf"\t6. Schedule and output the results \ n"); +printf"\t7. Exit \ n"); -printf"\ t---Please select (1~7):"); +scanf"%d",&select1); A Switch(Select1) at { - Case 1: -n=readFile (user); - Break; - Case 2: -N=input (User,n);//Receive Data in Break; - Case 3: ton=insertthehomework (user,n); + Break; - Case 4: the deletejob (user,n); * if(n>0) $n--;Panax Notoginseng Break; - Case 5: theSelect2=selectway ();//Select scheduling Algorithm + Break; A Case 6: theDealwith (Select2,user, averagetime,n);//Scheduling Calculations +Output (user,averagetime,n);//Output Results - Break; $ Case 7: $Exit0); - Break; - } the } -}
Source code Address: Https://github.com/helloyoucan/work/blob/master/work1.0.cpp
- 4. operation results and Analysis
Operation Result:
The results of the experiment were consistent with the expected results.
Four, Experimental Summary
Through this operation simulation scheduling experiment, fully understand how the system is transferred into the processing job, and scheduling operation is used in several scheduling algorithms.
Operating system---Experiment two, job scheduling simulation program