Operating Systems (COMP2006) 1st Semester 2019Page 1, CRICOS Number: 00301JOperating Systems (COMP2006)CURTIN UNIVERSITYDiscipline of ComputingSchool of Electrical Engineering, Computing and Mathematical SciencesAssignmentMultiple-Processor Scheduling SimulationDue Date: 4pm, Monday 6 May, 2019The goal of this simulation is to give you some experiences using POSIX Pthreads libraryfunctions for thread creations and synchronizations. You will learn how to solve the criticalsection problems using pthread_mutex_lock(), pthread_mutex_unlock(), pthread_cond_wait(),and pthread_cond_signal().Write a program scheduler in C under Linux environment to simulate the operations of threeProcessor Scheduling Simulation. The programs for this schedulershould include the followingfeatures.1) There is one Ready-Queue that contains a list of tasks to be serviced by three CPUs:CPU-1, CPU-2, and CPU-3. The Ready-Queue has a capacity for m tasks, and is initiallyempty.2) All CPUs are waiting for the arrival of the tasks in Ready-Queue. The arrival of a taskshould interrupt any of the waiting CPUs, which will grab the task, and execute it.3) Your scheduler includes a list of tasks, stored in file task_file. A task in the file isrepresented bytask# cpu_burstThe task# is a positive integer, and the cpu_burst is another positive integer (in second).Note that, each task may have different cpu_burst. Create yourself a task_file that contains100 tasks with random cpu_burst (1 to 50).4) Write a function task() that gets two tasks at a time from the task_file and puts it into theReady_Queue. For each task placed in the queue, the task() function should write thisactivity into a file, simulation_log.task#: cpu_burstArrival time: 13:42:51The Arrival time is the time the task is placed into Ready-Queue (actual time).Operating Systems (COMP2006) 1st Semester 2019Page 2, CRICOS Number: 00301J5) Write a function cpu() that simulates the operations of each of the three CPUs. When thereis at least one task in Ready-Queue, one of the CPUs takes the task from Ready-Queue,and executes it for its entire cpu_burst. In other words, it is a non pre-emptive scheduler.Simulate this event, for example, using a sleep call, proportional to the length of cpu_burst.6) Create three variables num_tasks, total_waiting_time and total_turnaround_time to beshared by the three CPUs. The three variables are initialized to 0.7) When CPU-1, for example, takes one task from the queue, CPU-1 should write thefollowing information in simulation_log:Statistics for CPU-1:Task #nArrival time: 13:42:55Service time: 13:42:57The Service time is the time the CPU picked up the task from the queue. Notice that thetask’s waiting time is its Service time minus Arrival time. CPU-1 then increases the valueof num_tasks by one, and total_waiting_time by the computed waiting time.8) When CPU-1, for example, finishes with one task, CPU-1 should write the followinginformation in simulation_log:Statistics for CPU-1:Task #nArrival time: 13:42:55Completion time: 13:42:59The Completion time is the time when CPU-1 finished servicing the task #n. TheCompletion time is computed from the Service time + cpu_burst. Notice that the task’sTurnaround time is its Completion time minus its Arrival time. CPU-1 then increases thevalue of total_turnaround_time by the computed Turnaround time.9) The task() function terminates when all tasks in task_file have been placed in ReadyQueue.The following information should be written in simulation_log:Number of tasks put into Ready-Queue: #of tasksTerminate at time: current timeThe current time is the time it terminates, e.g., 13:52:55.10) Each CPU terminates when there is no more task (NOT when Ready-Queue is empty). Eachterminating CPU, e.g., CPU-1 should write the following information into simulation_log:CPU-1 terminates after servicing x tasksOperating Systems (COMP2006) 1st Semester 2019Page 3, CRICOS Number: 00301Jwhere x is the total number of tasks the CPU has served.11) Finally, after all CPUs and task have terminated, the scheduler should write the followinginformation to simulation_log:Number of tasks: #of tasksAverage waiting time: w secondsAverage turn around time: t secondsThe Number of tasks is the total tasks serviced by the three CPUs, i.e, the value ofnum_tasks. The Average waiting time, and the Average turn around time are computed bydividing total_waiting_time and total_turnaround_time with num_tasks, respectively.Note, the assignment does not require high degree of precision for the time.Implementation (80%)1. Your scheduler creates a thread task that runs the task() function, and three threads CPU-1, CPU-2, and CPU-3 each runs the cpu() function. Each CPU thread blocks when ReadyQueueis empty, and task thread blocks when the queue is full.2. Create a First-In-First-Out Ready-Queue to be shared by threads task, CPU-1, CPU-2,and CPU-3. You have to synchronize the four threads when accessing the Ready-Queue.In essence, this is the bounded buffer producer-consumer problem.3. Use pthread mutual exclusion functions, pthread_mutex_lock(), pthread_mutex_unlock(),pthread_cond_wait(), and pthread_cond_signal() to solve the critical section andsynchronization problems in the scheduler. Make sure you consider all possible raceconditions in the scheduler.4. You have to describe / discuss in detail each of the variables, including its data structure,the threads that access them, and how mutual exclusion is achieved.5. Remember to clean up all resources created in your program.6. To test for the correctness of your program, you should run the program as follows:scheduler task_file mSet m to a value between 1 and 10.Operating Systems (COMP2006) 1st Semester 2019Page 4, CRICOS Number: 00301JInstruction for submission1. Assignment submission is compulsory. Students will be penalized by a deduction of tenpercent per calendar day for a late submission. An assessment more than seven calendardays overdue will not be marked and will receive a mark of 0.2. You must (i) submit a hard copy of your assignment report, (ii) submit the soft copy of thereport to the unit Blackboard (in one zip file), and (iii) put your program files e.g.,scheduler.c, makefile, and other files, such as test input, in your home directory, under adirectory named OS/assignment.3. Your assignment report should include: A signed cover page that includes the words “Operating Systems Assignment”, yourname in the form: family, other names, and a declaration stating the originality of thesubmitted work, that it is your own work, etc. Your name should be as recorded in thestudent database. Software solution of your assignment that includes (i) all source code for the programswith proper in-line and header documentation. Use proper indentation so that your codecan be easily read. Make sure that you use meaningful variable names, and delete allunnecessary comments that you created while debugging your program; and (ii) readmefile that, among others, explains how to compile your program and how to run the Detailed discussion on how any mutual exclusion is achieved and what threads accessthe shared resources. Description of any cases for which your program is not working correctly or how youtest your program that make you believe it works perfectly. Sample inputs and outputs from your running programs.Your report will be assessed (worth 20% of the ovrall assignment mark).4. Due dates and other arrangements may only be altered with the consent of the majority ofthe students enrolled in the unit and with the consent of the lecturer.5. Demo requirements: You may be required to demonstrate your program and/or sit a quiz during workshopsessions (to be announced).� the source code MUST be that submitted. The programs should run on any machinein the department labs.Failure to meet these requirements may result in the assignment not being marked本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp
网友评论