Sample Exam Questions
These are examples of a few different types of questions that have been asked
on other mid-terms, along with examples of full-credit, 2/3 credit, and 1/3 credit
answers to those questions. The purpose of these examples is to show you:
- What kinds of questions I am likely to ask
- What kinds of answers I am expecting to see
General considerations
For full credit I am generally looking to see that:
- You understand the question, including a clear understanding of
the meanings of all terms used in the question.
- You understand the concepts and issues that the question is exploring.
- You understand or are able to determine what the most important factors are.
- You can clearly express your understanding in a way that directly responds
to the question.
While the details are highly problem specific, partial credit will generally be awarded
in proportion to how well you were able to demonstrate how many of these things.
In the examples below:
- 2/3 credit was given for answers that clearly responded to the question,
but showed little depth or mastery of detail.
- 1/3 credit was given for answers that, while correct, were vague
and superficial.
- 0 credit would be given for answers that were incorrect, or that
failed to respond to the question.
"Principles" question
Why is it important to keep interface definitions distinct from implementations?
Give an example of a bad thing that could happen if this
principle were violated.
Full Credit Answer
If the interface is an implementation-agnostic specification of expected
behavior, it will be much easier to change the implementation, while
maintaining interface compatability. Otherwise, it may be difficult
to know what the actual interface is.
If the interface definition was "the current behavior of module X":
- individual clients are left to examine behavior and try
to guess the interface specifications. This greatly increases the
likelihood that future changes will break old clients.
- implementors are likely to find it impossible to change
the implementation without breaking some clients.
This will greatly constrain their ability to evolve
their software.
2/3 Credit Answer
Without a clear interface specification, nobody will be sure what the
right interface is, and a much greater chance that future implementations
will break some clients.
1/3 Credit Answer
Better interace definitions, and fewer fewer upwards compatability problems.
"Description" question
List the primary types of segments found in a process' virtual
address space and two characteristics (not contents) of each.
Full Credit Answer
The key segments in a process' address space are:
- text ... executable, read-only
- data ... read/write size, can change at run-time
- stack ... read/write, grown/shrunk by os as needed
- DLLs/shared libs ... executable, read-only other code segments loaded at load- or run-time
- thread stacks ... like program stacks,
but are probably allocated in the data segment and
may not be managed by OS
2/3 Credit Answer
- text ... executable code
- data ... read/write program data
- stack ... read/write, grows down
1/3 Credit Answer
"Process" question
Describe or illustrate (in detail) the sequence of operatins involved
in the processing of an illegal-address trap from a user-mode program
with a registered segmentation fault handler.
Full Credit Answer
- illegal address raises fault in CPU
- CPU loads new PC/PS from associated trap vector
- CPU pushes PC/PS at time of trap onto supervisor mode stack
- first level handler saves registers and status, forwards to 2nd level handler
- 2nd level handler determines it was a user-mode segmentation fault and that there
is a registered signal handler
- push PC/PS at time of trap onto user mode stack, and changes the return PC
(on the supervisor mode stack) to be the signal handler.
- 2nd level handler returns to 1st level handler
- 1st level handler restores registers and returns to user mode
- user mode execution resumes in the registered signal handler
2/3 Credit Answer
- CPU loads new PC/PS from associated trap vector
- CPU pushes PC/PS at time of trap onto supervisor mode stack
- OS trap handler saves registers and identifies cause of trap
- Trap handler finds signal handler and changes stack to return to it
- Restore registers, and return (to user-mode signal handler)
1/3 Credit Answer
- trap into operating system
- OS identifies cause
- OS identifies handler
- OS invokes signal handler
"Comparison" question
(a) List two key similarities between a (trap) system call and a procedure call.
(b) List two key differences between a (trap) system call and a procedure call.
Full Credit Answer
- System calls are like procedure calls in that they pass parameters, perform a
service, and return a result when the operation is complete.
- System calls run with different privileges, in a different address space.
Procedure calls are made with direct call instructions, while system calls are
a requested with an illegal instruction that is recognized by the trap handler.
Consquently, system calls are much more expensive than procedure calls.
2/3 Credit Answer
- parameter passing and return values
- subroutines are fast, system calls go into OS, which is slow
1/3 Credit Answer
- both are made from subroutine calls in C
- subroutines are in libraries, system calls are in OS