” 写作COMP 3430编程、C++程序调试COMP 3430 – Operating Systems Winter 2021ContentsDescription 1General submission requirements 2Question 1 – Simulating Scheduling 3Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3CPUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Overall structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Loading tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Running . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Tracking time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Sample output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Submitting your assignment 10DescriptionFor assignment 3, were looking for you to be able to implement scheduling policies, and to writeprograms that use threads and locks.Youre going to do this by implementing scheduling policies, and simulating a multi-CPU system withthreads as a producer-consumer-like problem.Assignment 3 is due Sunday, March 28th, 2021 at 11:59pm CDT (Winnipeg time).Franklin Bristow, Rasit Eskicioglu 1COMP 3430 – Operating Systems Winter 2021General submission requirementsSubmissions that Violate any of the following will not be evaluated, under any circumstances: All solutions must be written in C. No other languages are accepted. All solutions must include a working Makefile. Forget how to make a Makefile? Never knew how to make a Makefile? Thankfully,you can go to httpss://makefiletutorial.com and find some very easy to use basic examples. Your Makefile should contain a clean rule. Whenmake cleanis run from your directory, all the temporary files, including the executable should be removed(e.g., rm -f my_prog). All solutions must be compiled by issuing the command make in the directory containing theMakefile. No other build Commands are acceptable, even if documented in the README. All solutions must include a Markdown-formatted README file that minimally describes how torun your submission. All solutions must run to successful completion. Premature termination for any reason (no obviousoutput, Segmentation Fault, Bus Error, etc.) is considered to be a solution implementationthat does not run. Code that does not compile is also considered to be a solutionimplementation that does not run. Programs must produce no errors when compiled with the flags-Wall -Wpedantic -Wextra -WerrorNote that -Werror prevents your code from being compiled when warnings are present.If these flags are not in your Makefile, your submission will be treated as though it does notcompile.If your code does not compile, it will not be graded (you will receive a score of 0). Your code must compile and run on a machine on aviary.cs.umanitoba.ca. No late submissions will be accepted. The assignment deadline is enforced electronically. Submissionswill not be accepted by e-mail.Reminder: All submitted code will be evaluated using an automated similarity testing tool, alongsidecommonly available Online solutions for problems.Franklin Bristow, Rasit Eskicioglu 2COMP 3430 – Operating Systems Winter 2021Question 1 – Simulating SchedulingIn this question, youll be writing a simulator that implements different process scheduling policies,and simulates the behaviour of those scheduling policies on a multi CPU system using threads, whereeach CPU is one thread.PoliciesYour simulator will implement 3 different scheduling policies:1. Pure round-robin. A first-come-first-serve queue. This scheduler does not use priority.2. Shortest time to completion first. This scheduler does not use priority.3. A multi-level queue, where priority 1 tasks run first, in a round-robin fashion. Then, priority 2tasks run round-robin, etc. This is similar to the most basic implementation of MLFQ describedin our text.TasksThe tasks that will be loaded into your Simulation have multiple attributes: A name A type (which is used for classification for our statistics) Priority Amount of time to completion The odds of this task yielding the CPU due to going to an I/O operation, as a percentage out of100. When a task starts a timeslice, you should generate a random number to decide if therewill be I/O in the timeslice. If the task will do I/O (the random number is than the specifiedodds), it generates another random number between 0 and the full timeslice time, and run forthat amount of time.CPUsYour scheduling policy implementations will be used to evaluate how the different scheduling policiesbehave when different numbers of CPUs are running processes.When running the simulation with CPUs, your program should have at least +1 threads running:1 for each CPU, plus 1 for the scheduler itself.Franklin Bristow, Rasit Eskicioglu 3COMP 3430 – Operating Systems Winter 2021ImplementationOverall structureFigure 1: Assignment 3 architecture1. Scheduling policy determines which task is the next task in the queue of running tasks.2. The dispatcher notifies all waiting CPUs that a task is available.3. CPUs get tasks to run from the dispatcher when a task is available and start running (note: runninghere means that the CPU reduces the remaining time to completion to the task by thelength of the timeslice, or to 0, whichever is larger).4. CPUs return tasks to the scheduler queue on one of: Timeslice elapses, or Task does I/O (the amount is calculated by the odds_of_IO attribute of the task. Seebelow).CPUs update accounting Information on task, e.g., time left for the task.5. CPUs place tasks in the done area along with their stats, when the tasks are complete.6. When there are no tasks left, the program produces a report and terminates.Franklin Bristow, Rasit Eskicioglu 4COMP 3430 – Operating Systems Winter 2021Your implementation will require several locks, minimally where the CPUs get a task from the dispatcher,and where the CPUs return the task to the running queue. The level of granularity that youchoose to implement in terms of locking the queue here is your decision.Youre also going to need to use condition variables to tell CPUs that are not currently working on atask that a new task is available.Loading tasksTasks are loaded from a file, and are put in the schedulers ready queue before the start of the simulation(in other words, all tasks start at the same time, and all tasks start at time 0).The configuration file has a space-delimited format:task_name task_type priority task_length odds_of_IOThere are 4 types of tasks to run, which are indicated by an id: id 0 – Short tasks id 1 – Medium tasks id 2 – Long tasks id 3 – I/O tasksNote that I/O tasks are effectively the same as Long tasks, where the only difference is that I/O taskshave a higher chance of doing an I/O operation (see taskmaker.py) to get an idea of how the tasksare created).Heres an example of a single line thats generated by taskmaker.py, which represents the propertiesfor one task:io_task_1 3 1 10 50This line can be decoded into a Task in your system as: task_name: io_task_1 task_type: 3, io task priority: 1 (medium) task_length: 10 odds_of_IO: 50%You can find a file of tasks here. You can (and should!) make your own tasks.txt file withtaskmaker.py.Franklin Bristow, Rasit Eskicioglu 5COMP 3430 – Operating Systems Winter 2021RunningYour program should take two command-line arguments:1. The number of CPUs in the system youre simulating, and2. The scheduling policy that should be used to order tasks.Some examples:./a3q1 8 rr # 8 CPUs with round-robin scheduling policy./a3q1 4 stcf # 4 CPUs with shortest time to completion first policy./a3q1 2 mlfq # 2 CPUs with the multi-level feedback queue policyTracking timeHow you choose to track time for tasks is up to you, but One strategy that you can use for trackingtime to completion is to use a global variable tracking how much time has elapsed. Basically: aseach processor thread uses up a timeslice for a task, the processor thread should update the globalvariable with how much time it spent running that task.So, if a task uses 5 units of time (a complete timeslice, see Notes below), then that processor threadshould update the global time variable by 5. If a task uses only some of its timeslice (it yields becauseof an I/O), then the processor thread should update the global time variable by however much timethe task used before it yielded.When a task finishes (the time remaining for the current task is 0), the processor thread should copythe current time into that task and put it into the done area.OutputPrint the following statistics At the end of the simulation: average time from start to completion for each priority average time from start to completion for each typeSample outputUsing pure round-robin with 4 CPUs.Average run time per priority:Priority 0 average run time: 9999Franklin Bristow, Rasit Eskicioglu 6COMP 3430 – Operating Systems Winter 2021Priority 1 average run time: 8040Priority 2 average run time: 11187Average run time per type:Type 0 average run time: 861Type 1 average run time: 2476Type 2 average run time: 16384Type 3 average run time: 18239Franklin Bristow, Rasit Eskicioglu 7COMP 3430 – Operating Systems Winter 2021Notes Time can be integers, you dont have to use floating point numbers for times. Use a constant for the length of the timeslice. Set it to 5. This is a very open-ended assignment in terms of implementation. You are permitted to implementyour simulation as you see fit, provided it meets the expectations that are outlined above.AnalysisRun the scheduling algorithms that you wrote 5 times each with at least two different numbers forCPUs (e.g., 2 and 8), Generating an average and standard deviation all of your collected statistics. Youcan make your own set of tasks to do your analysis with.The statistics should be presented in your README.md as a table, present your results and provide awritten discussion comparing the algorithms. In your response, include answers the following questions: Are the distributions generated significantly different? How did the algorithms treat the queue differently, and how is that reflected in the data? How does the number of CPUs affect each scheduling policy?Franklin Bristow, Rasit Eskicioglu 8COMP 3430 – Operating Systems Winter 2021EvaluationImplementation5 points are awarded for code quality and design:Level Description0 The code is very poor quality (e.g., no comments at all, no functions, poor namingconventions for variables, etc).13 The code is low quality, while some coding standards are applied, their uses isinconsistent (e.g., inconsistent use of comments, some functions but functionsmight do too much, code is repeated that should be in a function, etc).45 The code is high quality, coding standards are applied consistently throughout thecode base.10 points are awarded for implementation (5 2):Level Description0 No attempt is made to answer this question or code does not run or compile.12 The submitted code is substantially incomplete. Many of the requirements for theassignment are not implemented.34 The submitted code is substantially complete, but some major parts are still missing(e.g., not all scheduling policies implemented).5 The submitted code is complete, all major functionality works as expected.Franklin Bristow, Rasit Eskicioglu 9COMP 3430 – Operating Systems Winter 2021ReportNote: If you earn 0 on the implementation for any reason, you will also earn 0 on the report.Level Criteria0 No attempt is made to answer this question12 A report is submitted, but is missing substantial parts and provides no meaningfulconclusion about the differences between scheduling policies.3 4 A report is submitted and coherent, but is missing some parts, or does not includeenough data points in the experiment to reasonably draw conclusions aboutscheduling policy behaviour.5 The report is submitted, Coherent, and complete. The conclusions about schedulingpolicies are consistent with reported statistics.Submitting your assignmentSubmissions will be made using the handin command available on all CS UNIX systems.If your files are in a folder named my_a3, you would run the command:handin 3430 a3 my_a3If you need more information, You can see man handin.Franklin Bristow, Rasit Eskicioglu 10请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。