CSCI 3323 (Principles of Operating Systems), Fall 2020:
Homework 3a
- Credit:
- 20 points.
Be sure you have read, or at least skimmed,
Chapter 2, section 2.4, and skimmed Chapter 6.
Answer the following questions. You may write out your answers by
hand and scan them, or you may use a word processor
or other program, but please submit a PDF or plain text
via e-mail to my TMail address.
(No links to shared files on Google Drive please.)
Please use a subject line that mentions the course and
the assignment (e.g.,
“csci 3323 hw 3a” or
“O/S hw 3a”).
- (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
follows:
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 to account at the same time as
a transfer from account to 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
not available).
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 just described.
Hint: There is a pretty simple solution to this problem,
based on something I mention in my lecture as sensible advice.
Include the Honor Code pledge or just the word “pledged”,
plus at least one of the following about
collaboration and help (as many as apply).1Text in italics is explanatory or something for you to
fill in.
For programming assignments, this should go in the body of the e-mail
or in a plain-text file pledge.txt (no word-processor files
please).
- 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 page”.)
- I worked with names of other students on this
assignment.
- 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
assignment.
(And here too, you only need to tell me about
significant help.)
Include a brief essay (a sentence or two is fine, though you can write
as much as you like) telling me what if anything you think
you learned from the assignment, and what if anything you found
found interesting, difficult, or otherwise noteworthy.
For programming assignments, it should go in the body of the e-mail
or in a plain-text file essay.txt (no word-processor files
please).
Footnotes
- ... 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.
2020-10-18