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%)

COMP2006作业代做、Operating Systems作业代写、c/c++程序设计作业调试
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
1. 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.
2. 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.
3. 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).
4. 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.
5. 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

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

微信:codinghelp

Operating Systems (COMP2006)的更多相关文章

  1. Modern Operating Systems(Ⅰ)——2014.12.15

    进程   进程模型     进程就是一个正在执行的程序的实例  值得注意的是,若一个程序运行了两遍,则算作两个进程 创建进程 在通用系统中,有四种主要事件导致进程的创建 ①系统的初始化 ②执行了 正在 ...

  2. [No00003D]操作系统Operating Systems信号量的代码实现Coding Semaphore &死锁处理Deadlock

    操作系统Operating Systems信号量的代码实现Coding Semaphore &死锁处理Deadlock 可以操刀了—从纸上到实际 从Linux 0.11 那里学点东西… 读磁盘 ...

  3. [No00003C]操作系统Operating Systems进程同步与信号量Processes Synchronization and Semaphore

    操作系统Operating Systems进程同步与信号量Processes Synchronization and Semaphore 进程合作:多进程共同完成一个任务 从纸上到实际:生产者− − ...

  4. [No00003A]操作系统Operating Systems 内核级线程Kernel Threads内核级线程实现Create KernelThreads

    开始核心级线程 内核级线程对多核的支持怎么样? 和用户级相比,核心级线程有什么不同? ThreadCreate 是系统调用,内核管理TCB ,内核负责切换线程 如何让切换成型? − − 内核栈,TCB ...

  5. Can We Make Operating Systems Reliable and Secure?

    Andrew S. Tanenbaum, Jorrit N. Herder, and Herbert Bos Vrije Universiteit, Amsterdam Microkernels-lo ...

  6. the virtual machine is configured for 64-bit guest operating systems

    Security--Virtualization--Inter(R) Virtualization Technolog 设置为enable 本机安装的是WIN 7 ,详细版本是:Windows 7 U ...

  7. Method of address space layout randomization for windows operating systems

    A system and method for address space layout randomization ("ASLR") for a Windows operatin ...

  8. CMPT 300 – Operating Systems

    Assignment 4 – Create Simple YetFunctional File SystemCMPT 300 – Operating SystemsPlease submit a zi ...

  9. 串口通信编程向导 Serial Programming Guide for POSIX Operating Systems

    https://www.cmrr.umn.edu/~strupp/serial.html#CONTENTS Introduction Chapter 1, Basics of Serial Commu ...

随机推荐

  1. 【转】协同开发中SVN使用规范试用

    转自:http://www.cnblogs.com/BraveCheng/archive/2012/07/02/2573617.html 协同开发中SVN使用规范试用 目标,要求 本次svn提交规范主 ...

  2. installshield中杀死某一个进程

    ///////////////////////////////////////////////// // Function prototypes. ////////////////////////// ...

  3. 数位dp 的简单入门

    时间紧张,就不讲那么详细了. 之前一直被深搜代码误解,以为数位dp 其实就是记忆化深搜...(虽说爆搜确实很舒服而且还好想) 但是后来发现数位dp 的标准格式其实是 预处理 + dp ...... 数 ...

  4. 避免’sudo echo x >’ 时’Permission denied’

    避免’sudo echo x >’ 时’Permission denied’ 甲: 示例sudo echo a > 1.txt-bash: 1.txt: Permission denied ...

  5. 全平台网页播放器兼容H5与Flash还带播放列表

    许久不发文了,2018年第一篇文章,写点干货--关于网页播放器的问题.嗯,实际上我是在52破解首发的,当做新人贴. 目前来说,网页播放器不少,随便找找都能找到一大堆,然而好用的就那么几个,比如ckpl ...

  6. Android屏幕旋转

    一个手机最基本的旋转方向有上面4种,而在Android开发中,涉及到屏幕旋转的地方很多,而且各个函数给出的角度值都不一样,比如 Activity的getRotate,Camera的setDisplay ...

  7. SQL入门(1): 创建/查询/更新/连接/视图/SSMS简介

    本文介绍SQL的基本查询语句 (1) select... from  * 表示全部, 选择的东西还可以进行简单的运算, 可以列别名 select * from student; -sage from ...

  8. Java项目使用SQLite数据库后无法启动的问题

    背景: Java > maven 的 jar 项目 功能是记录用户的每天的按键次数 使用 jar2exe 工具将 jar 转为 exe 可执行文件 原本项目中使用的Mysql数据库,使用Myba ...

  9. 阿里云各Linux发行版netcore兼容性评估报告---来自大石头的测试

    阿里云各Linux发行版netcore兼容性评估报告---来自大石头的测试 结论:    优先选择CentOS/Ubuntu,可选AliyunLinux(CentOS修改版)              ...

  10. xshll 连接ubuntu出现 ssh服务器拒绝了密码

    一般进行到这一步,可能是sshd的设置不允许root用户远程登录 首先修改一下vim /etc/sshd/ssh_config 修改成如下图: 如果找不到或修改不行 可以先用普通用户登录再su到roo ...