联系QQ:928900200
CSCI 3120 Operating Systems
Summer 2014 Handout 3
Assignment 2
Date Due: June 5, 2014 by 9:00 pm electronically in the SVN directory
https://svn.cs.dal.ca/3120/<your id>/a2 where <your id> is your bluenose username.
Problem 1
(5 marks)
a) Describe the actions taken by a kernel to context-switch between heavyweight processes.
Indicate if the order of certain actions is important.
b) What, if anything, changes for a context switch between threads?
Problem 2
(3 marks) Page 153, problem 3.18
What are the bene ts and the disadvantages of each of the following? Consider both the system
level and the programmer level. (note, item b is intentionally missing)
a) synchronous and asynchronous communication
c) send by copy and send by reference
d) xed-sized and variable-sized messages
Problem 3
(3 marks) Page 193, problem 4.18
Consider a multicore system and a multi-threaded program written using the many-to-many
threading model. Let the number of user-level threads in the program be grater than the number
of processing cores in the system. Discuss the performance implications of the following scenarios.
a) The number of kernel threads allocated to the program is less than the number of processing
cores.
b) The number of kernel threads allocated to the program is equal to the number of processing
cores.
c) The number of kernel threads allocated to the program is greater than to the number of
processing cores but less than the number of user-level threads..
1
Problem 4
(4 marks)
Consider the following set of processes, with the length of the CPU burst given in milliseconds
process burst time arrival time priority
P1 9 0 3
P2 5 2 2
P3 3 3 5
P4 8 5 4
P5 2 6 1
Draw four Gantt charts that illustrate the execution of these processes using the following
scheduling algorithms: FCFS, SJF, nonpreemptive priority where a smaller priority number implies
a higher priority, and preemptive priority where a smaller priority number implies a lower priority.
Problem 5
(3 marks)
Here is the shortest remaining time rst schedule for the processes of problem 4:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
--- - ----- --- ------- ------------- -----------------
P P P P P P P
1 2 3 5 2 1 4
Calculate the average wait time, average turnaround time, and average normalized turnaround
time of this schedule.
Problem 6
(20 marks)
Objective
The objective of this question is to have you become familiar with programming with the pthread
library interface and to try a program design that uses communicating threads and uses polling to
synchronize.
Overview
You are going to design a program using a model-view-controller framework. Your program will
have one main task to accomplish. A \model" thread will handle that task. You will have separate
threads that provide windows into the model's calculations. These threads are the viewers. You
will have one additional thread, called the controller, that will accept input from the user and relay
user commands, as appropriate, to the model and view threads.
All communication will be through shared memory.
2
The task
You have a choice of tasks to accomplish in this framework. Choose one of the tasks. Both are
essentially the same at their core and create a time series of results.
Task 1: The game of life
In the game of life, you are given a two-dimensional grid. Some cells are set as \alive" and the
others are \dead" as part of the initial con guration. As we move from one time step to the next,
cells either become/stay alive or die. The rules work as follows:
相关推荐
为您提供最贴心的服务,小泽竭诚为您服务. 定制,代写都是十元起价,小泽保证在能力范围内,尽量为您提供最精良的代码. ------DreamDimension
谭浩强编写 C语言程序设计C语言程序设计C语言程序设计C语言程序设计C语言程序设计C语言程序设计C语言程序设计C语言程序设计C语言程序设计C语言程序设计
这个是linux下,用c语言写的客户端和服务器通信的udp程序
c语言实现linux下多线程ping命令,可以ping一个网段,格式为./XX 14.215.177.38 14.215.177.40(以百度ip地址为例)
LINUX下JAVA程序与C语言程序通过SOCKET通信的简单例子.pdf
Linux下多线程计算圆周率 C语言 //实现一个用多线程计算 π(圆周率)的程序。 #include #include #include #include #define N 50000//设定计算次数 #define NUM 2//设定线程数,经过反复实验,在装有1个双核...
linux 下 可用的USB通信程序 dnw C语言源码 一些开发板 光盘只有Windows下的DNW 这个是linux下的 测试大多数时候可用
线程如何去创建 ,多线程如何控制输出!互斥控制!
C语言模拟实现Linux文件系统 1、在内存中开辟一块空间来模拟文件系统的运行,不读写硬盘。 2、面向单用户、单任务,不考虑并发,不考虑文件属主、组等概念。 3、程序开始后,初始化并接收用户输入。若输入”enter”...
c语言多线程c语言多线程
本文我们将介绍在Linux 下编写多进程和多线程程序的一些初步知识。 1 引言 对于没有接触过 Unix/Linux 操作系统的人来说,fork 是最难理解的概念之一:它执行 一次却返回两个值。fork 函数是Unix 系统最杰出的成就之...
C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计教案C语言程序设计...
对Linux下C语言编程--线程操作作了详细的说明
嵌入式Linux C语言应用程序设计:嵌入式Linux C语言应用程序设计
基础的嵌入式开发入门教程 Linux下C语言程序开发
张玉生《C语言程序设计》双色版 教材课后习题答案,仅供参考,大家一定要自己做一遍再校对答案,实验书的答案已经以文章的形式发布了。
c语言程序设计基础课后习题答案 c语言程序设计基础课后习题答案 c语言程序设计基础课后习题答案 c语言程序设计基础课后习题答案
两个线程共享变量a,一个负责加一,一个负责输出 通过信号灯的pv操作完成
C语言与实现测试-线程(Sieve);C语言与实现测试-线程(SORT);C语言与实现测试-线程(SPIN)三个示例源程序
三个多线程经典代码只需要5分 转别人的,没分下载了 混点分,请多多支持