讲解:C++ Operating Systems Assignment 1C/C++

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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,222评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,455评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,720评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,568评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,696评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,879评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,028评论 3 409
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,773评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,220评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,550评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,697评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,360评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,002评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,782评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,010评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,433评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,587评论 2 350

推荐阅读更多精彩内容

  • Introduction函数主要功能见函数名主要过程见注释注:queue[0]对应Queue2,Queue[1]~...
    k841240阅读 112评论 0 0
  • 文/苏子游 小的时候,我们过得很快乐,那时候看到什么相信什么,喜欢就喜欢,讨厌就讨厌,活得纯粹与简单。 长大了,我...
    苏子游阅读 467评论 0 12
  • 因为追美股,已经很难得过了11点还没睡。 打电话才知道,今天正是清明时节。刚微信群里听说老外婆上午过世,享年94岁...
    与姝会友阅读 153评论 0 0
  • 洛阳之旅己过去二个月了,因为手欠点了日更。更因为很想写写游记总是没有灵感,感觉得就是无处下笔。 零零碎碎乱七八糟的...
    文文稚稚阅读 855评论 2 5
  • 混乱不是问题,找到规律是关键所在。反思过去,计划未来,就可以总结规律、把握趋势,从容不迫。 如何月反思,反思过去的...
    小小效能阅读 443评论 0 0