`
guoyiqi
  • 浏览: 958530 次
社区版块
存档分类
最新评论

C语言程序代写(Linux下线程)

 
阅读更多

联系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:

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics