CSE 120: Homework #1
Spring 2023
Each question is worth equal number of points. When a question asks you to
describe or explain, your answers can be relatively brief. The [name]
tags give scholarly attribution to authors of other OS textbooks who
wrote the question (you do not need the textbook to be able to answer
the question, though). Please turn in your answers as PDF files to Canvas.
- How do hardware and OS work together to handle interrupts?
When an interrupt happens, what tasks are handled by the hardware and what are handled by the OS?
- [Silberschatz] Some computer systems do not provide a privileged
mode of operation in hardware. Is it possible to construct a secure
operating system for these computers? Give arguments both that it is
and that it is not possible. (By a secure operating system, we mean
that a user program is not able to corrupt the kernel, prevent it from
running, crash the system, violate memory protection, etc.)
- [Silberschatz] Which of the following instructions should be
privileged? Give a one-sentence explanation for why.
a) Set value of timer
b) Read the clock
c) Set memory content to zero
d) Turn off interrupts
e) Switch from user to monitor (kernel) mode
- Can there be any situations where polling is better than interrupts for handling I/O requests?
What do you think is the criteria for deciding which is better?
- [Anderson 2.13] Suppose you have to implement an operating system
on hardware that supports interrupts and exceptions but does not have
an explicit syscall instruction. Can you devise a satisfactory
substitute for syscalls using interrupts and/or exceptions? If so,
explain how. If not, explain why. (In this context, the syscall
instruction is the instruction used by a user-level process to invoke
a system call in the operating system.)
- Consider the following C program:
#include <stdlib.h>
int main (int argc, char *arg[])
{
fork ();
if (fork ()) {
fork ();
} else {
char *argv[2] = {"/bin/ls", NULL};
execv (argv[0], argv);
fork ();
}
}
a. How many total processes are created (including the first process
running the program)? (Note that execv is just one of
multiple ways of invoking exec.)
b. How many times does the /bin/ls program execute?
[Hint: You can always add debugging code, compile it, and run the
program to experiment with what happens.]