CS439: Principles of Computer Systems
Due: 7:45a Thursday, September 12, 2013 Homeworks
must be submitted electronically. Please refer to the
homework turnin instructions.
What differentiates a program, an executable, and a process?
Define three styles of switching from user mode to supervisor mode.
From Anderson and Dahlin, Ch1 question 1:
Suppose a computer
system and all of its applications are completely bug free. Suppose
further that everyone in the world is completely honest and
trustworthy. In other words, we do not need to consider fault isolation.
How should the operating system allocate the processor? Should
it give all of the processor to each application until it no longer
needs it? If there are multiple tasks ready to execute at the same
time, should it schedule the task with the least amount of work to do
or the most? Justify your answer.
You may assume a uniprocessor.
Given the following piece of code:
main(int argc, char**argv)
How many different copies of the variable c are there? What
are their values?
System Calls vs. Procedure Calls:
How much more expensive is a system call than a procedure call? Write
a simple test program to compare the cost of a simple procedure call
to a simple system call ("getuid()" is a good candidate on
UNIX; see the man page.) (Note: be careful to prevent the optimizing
compiler from "optimizing out" your procedure calls. Do not
compile with optimization on.)
- Explain the difference (if any) between the time required by your
simple procedure call and simple system call by discussing what work
each call must do (be specific). [Note: Do not provide the source code
for your program, just the results].
Hint: You should use system calls such as gethrtime()
or gettimeofday() for time measurements. Design your code such
that the measurement overhead is negligible. Also, be aware that timer
values in some systems have limited resolution (e.g., millisecond