COMP2006 操作系统

BigData
• 阅读 703

COMP2006
Operating Systems (COMP2006) 1
st Semester 2019
Page 1, CRICOS Number: 00301J
Operating Systems (COMP2006)
CURTIN UNIVERSITY
Discipline of Computing
School of Electrical Engineering, Computing and Mathematical Sciences
Assignment
Multiple-Processor Scheduling Simulation
Due Date: 4pm, Monday 6 May, 2019
The goal of this simulation is to give you some experiences using POSIX Pthreads library
functions for thread creations and synchronizations. You will learn how to solve the critical
section 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 three
Processor Scheduling Simulation. The programs for this schedulershould include the following
features.
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 initially
empty.
2) All CPUs are waiting for the arrival of the tasks in Ready-Queue. The arrival of a task
should 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 is
represented by
task# cpu_burst
The 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 contains
100 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 the
Ready_Queue. For each task placed in the queue, the task() function should write this
activity into a file, simulation_log.
task#: cpu_burst
Arrival time: 13:42:51
The Arrival time is the time the task is placed into Ready-Queue (actual time).
Operating Systems (COMP2006) 1
st Semester 2019
Page 2, CRICOS Number: 00301J
5) Write a function cpu() that simulates the operations of each of the three CPUs. When there
is 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 be
shared 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 the
following information in simulation_log:
Statistics for CPU-1:
Task #n
Arrival time: 13:42:55
Service time: 13:42:57
The Service time is the time the CPU picked up the task from the queue. Notice that the
task’s waiting time is its Service time minus Arrival time. CPU-1 then increases the value
of 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 following
information in simulation_log:
Statistics for CPU-1:
Task #n
Arrival time: 13:42:55
Completion time: 13:42:59
The Completion time is the time when CPU-1 finished servicing the task #n. The
Completion time is computed from the Service time + cpu_burst. Notice that the task’s
Turnaround time is its Completion time minus its Arrival time. CPU-1 then increases the
value 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 tasks
Terminate at time: current time
The 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). Each
terminating CPU, e.g., CPU-1 should write the following information into simulation_log:
CPU-1 terminates after servicing x tasks
Operating Systems (COMP2006) 1
st Semester 2019
Page 3, CRICOS Number: 00301J
where 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 following
information to simulation_log:
Number of tasks: #of tasks
Average waiting time: w seconds
Average turn around time: t seconds
The Number of tasks is the total tasks serviced by the three CPUs, i.e, the value of
num_tasks. The Average waiting time, and the Average turn around time are computed by
dividing 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 ReadyQueue
    is 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 and
    synchronization problems in the scheduler. Make sure you consider all possible race
    conditions 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 m
    Set m to a value between 1 and 10.
    Operating Systems (COMP2006) 1
    st Semester 2019
    Page 4, CRICOS Number: 00301J
    Instruction for submission
  7. Assignment submission is compulsory. Students will be penalized by a deduction of ten
    percent per calendar day for a late submission. An assessment more than seven calendar
    days overdue will not be marked and will receive a mark of 0.
  8. You must (i) submit a hard copy of your assignment report, (ii) submit the soft copy of the
    report 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 a
    directory named OS/assignment.
  9. Your assignment report should include:
    A signed cover page that includes the words “Operating Systems Assignment”, your
    name in the form: family, other names, and a declaration stating the originality of the
    submitted work, that it is your own work, etc. Your name should be as recorded in the
    student database.
    Software solution of your assignment that includes (i) all source code for the programs
    with proper in-line and header documentation. Use proper indentation so that your code
    can be easily read. Make sure that you use meaningful variable names, and delete all
    unnecessary comments that you created while debugging your program; and (ii) readme
    file 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 access
    the shared resources.
    Description of any cases for which your program is not working correctly or how you
    test 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).
  10. Due dates and other arrangements may only be altered with the consent of the majority of
    the students enrolled in the unit and with the consent of the lecturer.
  11. Demo requirements:
    You may be required to demonstrate your program and/or sit a quiz during workshop
    sessions (to be announced).
     the source code MUST be that submitted. The programs should run on any machine
    in the department labs.
    Failure to meet these requirements may result in the assignment not being marked

WX:codehelp

点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Wesley13 Wesley13
4年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Easter79 Easter79
4年前
typeScript数据类型
//布尔类型letisDone:booleanfalse;//数字类型所有数字都是浮点数numberletdecLiteral:number6;lethexLiteral:number0xf00d;letbinaryLiteral:number0b101
Wesley13 Wesley13
4年前
VBox 启动虚拟机失败
在Vbox(5.0.8版本)启动Ubuntu的虚拟机时,遇到错误信息:NtCreateFile(\\Device\\VBoxDrvStub)failed:0xc000000034STATUS\_OBJECT\_NAME\_NOT\_FOUND(0retries) (rc101)Makesurethekern
Wesley13 Wesley13
4年前
FLV文件格式
1.        FLV文件对齐方式FLV文件以大端对齐方式存放多字节整型。如存放数字无符号16位的数字300(0x012C),那么在FLV文件中存放的顺序是:|0x01|0x2C|。如果是无符号32位数字300(0x0000012C),那么在FLV文件中的存放顺序是:|0x00|0x00|0x00|0x01|0x2C。2.  
Wesley13 Wesley13
4年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
4年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Wesley13 Wesley13
4年前
Java日期时间API系列36
  十二时辰,古代劳动人民把一昼夜划分成十二个时段,每一个时段叫一个时辰。二十四小时和十二时辰对照表:时辰时间24时制子时深夜11:00凌晨01:0023:0001:00丑时上午01:00上午03:0001:0003:00寅时上午03:00上午0
Wesley13 Wesley13
4年前
MBR笔记
<bochs:100000000000e\WGUI\Simclientsize(0,0)!stretchedsize(640,480)!<bochs:2b0x7c00<bochs:3c00000003740i\BIOS\$Revision:1.166$$Date:2006/08/1117
Python进阶者 Python进阶者
2年前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这
BigData
BigData
Lv1
落叶他乡树,寒灯独夜人。
文章
5
粉丝
0
获赞
0