Introduction函数主要功能见函数名主要过程见注释注:queue[0]对应Queue2,Queue[1]~[3]对应优先级为3~5的Queue1void ReadFromFile(vector AllProcess,char FileName){fstream fin;int i=0;fin.open(FileName,ios::in);Process tmp;while(fin>>tmp.Name>>tmp.StartTime>>tmp.Priority>>tmp.Age>>tmp.Ticket){tmp.EndTime=-1;tmp.RunTime=0;tmp.ReadyTime=-1;tmp.id=i;tmp.Turn=0;AllProcess.push_back(tmp);i++;}sort(AllProcess.begin(),AllProcess.end(),cmp);fin.close();}*RequirementCOMP SCI 3004/7064 - Operating Systems Assignment 1DUE: 9:00pm, 13th Sept, 2017Important Notes• Handins:– The deadline for submission of your assignment is 9pm the 13th of Sept, 2017.– For undergraduate students, you may do this assignment as a team of two stu-dents and hand in one submission per team.– For postgraduate students, you have to do this assignment individually and makeindividual submissions.– All implementations have to be done in C++.– You need to submit your source code using the web submission system. You shouldattach you and your partner’s name and student number in your submission.– Late submissions will attract a penalty: the maximum mark you can obtain will bereduced by 25% per day (or part thereof) past the due date or any extension you aregranted.• Marking scheme:– 12 marks for online testing on 3 standard tests (4 marks per test).– 3 marks for the structure of your code and comments.If you have any questions, please send them to the student discussion forum. This way youcan all help each other and everyone gets to see the answers.The assignmentThe aim of this assignment is to improve your learning experience in the process schedulingalgorithms. You are required to design an online ticketing system for Coopers Stadium’s public-seating section (red-coloured section in Coopers Stadium’s seats map shown in Figure 1)In the system, all the customers are grouped into five priority classes, ranged from 1 to5, according to their loyalty (accumulated points) to this ticketing system. A larger prioritynumber indicates a higher priority. All ticketing processes (purchase/cancellation) generatedby a customer are assigned with the same priority number of that customer. To maximisethe system service performance, you are required to implement a customer process schedulingalgorithm using multi-level queue strategy with two queues: a high priority Queue 1 and a lowpriority Queue 2. Queue 1 has absolute priority over Queue 2. In other words, a customerprocess in Queue 2 will only be processed if there is no process in Queue 1. There is a threshold(=2) that is used to determine whether a process should remain in Queue 1 (priority > threshold)or Queue 2 (priority threshold). Detailed actions in these two queues are listed below:Queue 1: This is the high priority queue. All processes in this queue are treated in theway of combined Highest Priority First (HPF) and Round Robin. That is, select the highestpriority process and process it for a ticket quota of 5 tickets (= 5 units of time quantum) non-preemptively, then move the process to the end of Queue 1. Processes of the same priority are1Figure 1: Stadium Map.selected in their arrival order. The priority of a process in this queue is decreased by one every5 runs of this process, i.e. when the process has processed 25 tickets under its current priority.If a process’s priority goes below the threshold (=2), it is demoted from Queue 1 to Queue 2.Queue 2: This is the low priority queue. ProcesC++代写 Operating Systems Assignment 1调试C/C++语言ses in this queue are handled in RoundRobin. That is, select a process according to First Come First Serve and process it for a ticketquota of 20 tickets (= 20 time units) preemptively, then move the process to the end of Queue 2.Note: once a running process P in this queue is interrupted by a new arrival process in Queue1, P will be preempted immediately even if it has not used up its time quantum. If the priorityof a process in this queue reaches the threshold (=2) due to the Ageing mechanism below, it ispromoted from Queue 2 to Queue 1.Ageing mechanism: Because processes in Queue 2 will execute only when Queue 1 isempty, starvation may occur, i.e., some processes in Queue 2 may never get to run. To resolvethis starvation issue, you must implement a mechanism which ages each process. This need notbe done for every process run as it will slow the system down, but once every 9th run. That is,if a process has waited 8 runs (the interrupted process is counted as one run) of other processessince its last run, its priority number will be increased by one. In this way, the priority of eachprocess in Queue 2 increases gradually in proportion to the waiting time since the last run.Note: For the case if three processes of the same priority — a new arrival process A, a2preempted process B of Queue 1 (by Round-Robin) and a promoted process C from Queue 2 toQueue 1 — are put to the end of Queue 1 at the same time, their order will be A ! B ! C.Same rule is applied in Queue 2 regardless of process priority, i.e., new arrival first, preemptedsecond and demoted last, if the three processes come to the end of Queue 2 at the same time,regardless of their priorities.Test data formatInputEach process is identified by a line in the input file (see “input-sample.txt” in the assignmentfolder). The line describes the process ID, arrival time, priority, age and the total ticketsrequired. For example s1 3 1 0 50 describes a process s1 which arrived at time 3 with priority 1and age 0, and requires 50 tickets. One ticket processing consumes one time unit.OutputThe output provides information of each process execution. The line starts with the process ID,arrival and termination times, ready time (the first time the system processes the process) anddurations of running and waiting (see “output-sample.txt” in the assignment folder).You may monitor the execution of your code by displaying all its intermediate outputs asshown in the sample “detailed-output.txt” in the assignment folder. Note that this is merelyfor your own code debugging purpose, and should not be presented in the final output.Web-submission instructions• First, type the following command, all on one line (replacing xxxxxxx with your studentID):svn mkdir –parents -m “OS”• Then, check out this directory and add your files:svn co cd assignment1svn add TicketBooker.cppsvn add StudentFile1.cppsvn add StudentFile2.cpp···svn commit -m “assignment1 solution”• Next, go to the web submission system at:Navigate to 2017, Semester 2, Operating Systems, Assignment 1. Then, click Tab “MakeSubmission” for this assignment and indicate that you agree to the declaration. Theautomark script. will then check whether your code compiles. You can make as manyresubmissions as you like. If your code does not compile you won’t get any marks for theonline testing part.• We will test your codes by the following Linux commands:g++ TicketBooker.cpp -o TicketBooker./TicketBooker input.txt > output.txt3转自:http://ass.3daixie.com/2019030627560489.html
讲解:C++ Operating Systems Assignment 1C/C++
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Introduction函数主要功能见函数名主要过程见注释注:queue[0]对应Queue2,Queue[1]~...