Introduction此处我分别实现两种调度方式运行方式 ./程序名 输入文件名 停顿时间 时间片长度具体的运行结果截图如下:Requirement2/7/2018 Programming Assignment 1 - Scheduling Simulation1/5Programming Assignment 1 ‐ Scheduling Simula?onDue Monday by 11:59pm Points 100 Submitting a file upload File Types zipAvailable until Feb 14 at 11:59pmSubmit AssignmentUpdates20180203: added information about output validator20180130: updated sample outputs to fix bug in SPN outputIntroduc?onIn this programming assignment, you’ll implement two scheduling algorithms (RoundRobin and ShortestJob Next) and run them on a specified mix of processes. The input to the program will specify schedulerparameters such as the time slice (for preemptive scheduling algorithms) and the length of time that aprocess is unavailable to run when it blocks. Input will also include a list of processes to be scheduled.Command LineYour program should accept three arguments on the command line:1. The input file name2. block_duration: the decimal integer time length that a process is unavailable to run after it blocks3. time_slice: the decimal integer length of the time slice for the RoundRobin schedulerInput FormatThe input file, specified as the first command line argument, contains the list of processes to schedule.All numeric values in the input file are decimal integers. The time unit doesn’t matter; you can think of it asmilliseconds.This input file will contain 1 line per process. Lines will be sorted in increasing order of arrival time in thesystem. Each line will have the following format:name arrival_time total_time block_intervalname is a sequence of nonblank characters representing the name of the processarrival_time is the time at which the process arrives in the systemtotal_time is the total amount of CPU time which will be used by the process2/7/2018 Programming Assignment 1 - Scheduling Simulation2/5block_interval is the interval at which the process will block for I/O. When a process blocks, it isunavailable to run for the time specified by block_duration in the scheduler parameter file.Programming TaskYour program should simulate the RoundRobin (preemptive) and Shortest Process Next (nonpreemptive)scheduling algorithms. You’ll need to maintain a simulation time in your program, starting at 0. For eachinterval, determine the process to run according to the scheduling algorithm, and determine when theinterval ends, depending on the CPU time left until the process blocks, the time slice length (for RoundRobin), and when the process terminates.For either algorithm, processes which reenter the ready queue after being blocked or entering the systemshould be placed on the end of the queue.For Shortest Process Next (SPN), use the block_interval (or the total time left, whichever is shortest) of theprocesses in the ready list to determine which process to run next. You don’t need to calculate the weightedaverage of past CPU time usage, since the block_interval is fixed.You may want to look at using std::priority_queue to maintain the blocked process list and the ready list forSPN, but this is not required.Output FormatAll output should be written to standard output. For each scheduling algorithm, a set of lines should bewritten consisting of:A single line with the name of the scheduling algorithm (RR or SPN), followed by the block_duration (forboth algorithms) and time_slice (for RR) as specified on the command line. Values should be separatedby spaces.One line for each interval during which a process is running or the system is idle. The line should consistof a single space, followed by the current simulation time (starting at 0), followed by the process name(or ““ if no process is running), the length of the interval, and a status code: “B” for blocked, “S” fortime slice ended, “T” if the process terminated, or “I” for an idle interval. The fields should be separatedby the tab character, ‘\t’.After all jobs have terminated, write a line consisting of a single space, the simulation time at which thelast job terminated, a tab character, the string ““, another tab character, and the averageturnaround time of all processes (floating point value).Sample Input and OutputHere is a sample input file, program1_sample1.txt :A 0 100 25B 1 50 20C 2 90 452/7/2018 Programming Assignment 1 - Scheduling Simulation3/5Here is a sample output from running this sample with block_duration = 20 and time_slice = 10:RR 20 100 A 10 S10 B 10 S20 C 10 S30 A 10 S40 B 10 B50 C 10 S60 A 5 B65 C 10 S75 B 10 S85 A 10 S95 C 10 S105 B 10 B115 A 10 S125 C 5 B130 A 5 B135 B 10 T145 5 I150 C 10 S160 A 10 S170 C 10 S180 A 10 S190 C 10 S200 A 5 B205 C 10 S215 C 5 T220 5 I225 A 10 S235 A 10 S245 A 5 T250 204SPN 200 A 25 B25 B 20 B45 A 25 B70 B 20 B90 A 25 B115 B 10 T125 C 45 B170 A 25 T195 C 45 T240 185.667Here’s a sample output from the same process list, with a block_duration of 50 and a time_slice of 10:RR 50 100 A 10 S10 B 10 S20 C 10 S30 A 10 S40 B 10 B50 C 10 S60 A 5 B2/7/2018 Programming Assignment 1 - Scheduling Simulation4/565 C 10 S75 C 10 S85 C 5 B90 10 I100 B 10 S110 B 10 B120 A 10 S130 A 10 S140 C 10 S150 A 5 B155 C 10 S165 C 10 S175 B 10 T185 C 10 S195 C 5 T200 5 I205 A 10 S215 A 10 S225 A 5 B230 50 I280 A 10 S290 A 10 S300 A 5 T305 229SPN 500 A 25 B25 B 20 B45 C 45 B90 A 25 B115 B 20 B135 5 I140 C 45 T185 B 10 T195 A 25 B220 50 I270 A 25 T295 224More sample inputs and output will be supplied closer to the due date.Valida?ng Your OutputYour output may vary slightly depending on the order in which you pick from multiple jobs which are eligibleto run next under the particular scheduling algorithm. Any valid schedule for the particular algorithm isacceptable. The RoundRobin schedules may vary significantly depending on what order jobs are returnedto the ready list.I have supplied a program which you can run to validate your RoundRobin output. The program will readyour output file, and report whether the RoundRobin schedule appears correct (it will catch most, but not all,errors in the schedule and give an explanation of the error found).2/7/2018 Programming Assignment 1 - Scheduling Simulation5/5To run the validation program, download and unzip this file inside your virtualmachine: RR_Validate_executable.zip. You’ll see two subdirectories, “32” and “64”. Each contains anexecutable file named “rr_validate”. Use the version in the “64” subdirectory if you have a 64bit virtualmachine, and the version in the “32” subdirectory if you have a 32bit virtual machine. Copy the appropriateversion of rr_validate to the directory where your input and output files are located. Then run the commandwith a first argument of the input file, and the second argument of your output file. The program will analyzeyour output and report if your schedule is a valid RoundRobin schedule (it will ignore the SPN schedule).For example:./rr_validate program1_sample1.txt your_schedule.outThe analysis will be written to standard output.Submi?ng Your ProgramExport your project from NetBeans as a zip file called Program1.zip, using File > Export Project > To ZIP…The resulting zip file should be submitted through Canvas.Ques?ons?Please post questions of general interest in the Programming Assignment 1 questions, problems, andcomments discussion.& 转自:http://ass.3daixie.com/2018052610496698.html
讲解:CScheduling Simulationphp、Scheduling Simulation
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- Different Components NodeManager The NodeManager is YARN‘...
- 我发现我从来不会想着来留言,不知道为什么现在用qq做的事情非常少了其实我一直都喜欢花时间来写写东西,笔耕不辍。也许...