CSCI 3323 (Principles of Operating Systems), Fall 2017:
- 55 points.
Be sure you have read, or at least skimmed,
Chapter 2, sections 2.4 through 2.7, and skimmed Chapter 6.
Please include with each part of the assignment the Honor Code pledge or
just the word ``pledged'', plus one or more of the following about
collaboration and help (as many as apply).1Text in italics is explanatory or something for you to
For written assignments, it should go right after your name and
the assignment number; for programming assignments, it should go
in comments at the start of your program(s).
- This assignment is entirely my own work.
(Here, ``entirely my own work'' means that it's
your own work except for anything you got from the
assignment itself -- some programming assignments
include ``starter code'', for example -- or
from the course Web site.
In particular, for programming assignments you can
copy freely from anything on the ``sample programs
- I worked with names of other students on this
- I got help with this assignment from
source of help -- ACM
tutoring, another student in the course, the instructor, etc.
(Here, ``help'' means significant help,
beyond a little assistance with tools or compiler errors.)
- I got help from outside source --
a book other than the textbook (give title and author),
a Web site (give its URL), etc..
(Here too, you only need to mention significant help --
you don't need to tell me that you
looked up an error message on the Web, but if you found
an algorithm or a code sketch, tell me about that.)
- I provided help to names of students on this
(And here too, you only need to tell me about
Answer the following questions. You may write out your answers by
hand or using a word processor or other program, but please submit
hard copy, either in class or in one of my mailboxes (outside my
office or in the ASO).
- (10 points)
Solve the dining philosophers problem with monitors
rather than semaphores.
(I'm looking for pseudocode here, similar to what I showed
in class for the bounded-buffer problem.)
(Despite what I said in class about reading the literature,
for this assignment do not look for a solution online
or in another book; this is a problem you can and should try
to solve just based on what we've done in this class.)
- (10 points)
Five batch jobs (call them
) arrive at
a computer center at almost the same time, in the order
Their estimated running times (in minutes)
and priorities are as follows, with 5 indicating
the highest priority:
For each of the following scheduling algorithms, determine
the turnaround time for each job and the average turnaround
time. Assume that all jobs are completely CPU-bound (i.e.,
they do not block).
(Before doing this by hand, decide how much of
programming problem 1 you want to do.)
- First-come, first-served (run them in alphabetic
order by job name).
- Shortest job first.
- Round robin, using a time quantum of 1 minute.
- Round robin, using a time quantum of 2 minutes.
- Preemptive priority scheduling.
- (10 points)
Suppose that a scheduling algorithm favors processes
that have used the least amount of processor time
in the recent past. Why will this algorithm
favor I/O-bound processes yet not permanently starve
CPU-bound processes, even if there is always an I/O-bound
process ready to run?
- (10 points)
Suppose you are designing an electronic funds transfer system,
in which there will be many identical processes that work as
Each process accepts as input an amount of money to transfer,
the account to be credited, and the account to be debited.
It then locks both accounts (one at a time), transfers the
money, and releases the locks when done. Many of these
processes could be running at the same time.
Clearly a design goal for this system is that two transfers
that affect the same account should not take place at the
same time, since that might lead to race conditions.
However, no problems should arise from doing a transfer
from, say, account
at the same time as
a transfer from account
, so another design
goal is for this to be possible.
The available locking mechanism is fairly primitive:
It acquires locks one at a time, and there is no provision
for testing a lock to find out whether it is available
(you must simply attempt to acquire it, and wait if it's
A friend proposes a simple scheme for locking the accounts:
First lock the account to be credited; then lock the account
to be debited. Can this scheme lead to deadlock?
If you think it cannot, briefly explain why not. If you think
it can, first give an example of a possible deadlock situation,
and then design a scheme that avoids deadlocks, meets the
stated design goals, and uses only the locking mechanism
Do the following programming problems.
You will end up with at
least one code file per problem.
Submit your program source (and any other needed files)
by sending mail to
email@example.com with each file as an attachment.
Please use a subject line that mentions the course and
the assignment (e.g.,
``csci 3323 hw 3'' or
``O/S hw 3'').
You can develop your programs on any system that provides the
needed functionality, but I will test them on one of the department's
Linux machines, so you should probably make sure they work
in that environment before turning them in.
- (15 points)
The starting point for this problem is a C++ program
that simulates execution of a scheduler,
i.e., generates solutions to problems such as the one in
the written part of this assignment.
Comments describe input and desired output.
Currently the program simulates only the FCFS algorithm.
Your mission is to make it simulate one or more of the other
algorithms mentioned in the written problem
(FCFS, SJF, round robin using time quantums of 1 minute and 2 minutes,
and preemptive priority scheduling).
You will get full credit for simulating one algorithm,
extra points for simulating additional algorithms.
Keep in mind that arrival times may be nonzero, and it doesn't make
sense to schedule a job that hasn't arrived yet.
Note that in the sample input all arrival times are zero.
But your code should work even if some arrival times are not zero,
and in fact one of my tests I'll use to evaluate your work has
some non-zero arrival times. A word of caution?
The starter code also makes use of some
library classes (string and vector) that I think
most of you have used but some of you may not have.
string is functionally pretty similar to strings in languages
such as Java and Scala;
vector represents a templated expandable array
(i.e., one with a type parameter that lets you specify the type of
elements in the array).
I'm cautiously optimistic that between the starter code,
this toy example
of using vector,
and what you can find on the Web
about these classes (the Wikipedia articles seem okay),
you will be able to use them to implement your choice of scheduling
If you don't remember, or didn't learn, how to compile C++ from the
command line in Linux:
g++ -Wall -pedantic scheduler.cpp
(-pedantic is optional but does flag any nonstandard usage.
-Wall is optional too but so potentially useful that
I strongly recommend its use.)
- (Optional -- up to 10 extra-credit points)
Write a program to test your solution to
See the writeup for the optional programming problem for Homework 2
for some suggestions about suitable platforms.
- ... apply).1
Credit where credit is due:
I based the wording of this list on a posting to a SIGCSE mailing
list. SIGCSE is the ACM's Special Interest Group on CS Education.