100% correct answers ( graded A+ )
What are the differences between a trap and an interrupt? - answer : The CPU initiates a trap.
Usually an I/O device initiates an
interrupt. Traps are often used to catch arithmetic conditions (e.g. over-
flow, divide by zero). Interrupts are used to interrupt the CPU and run an
interrupt service routine to handle some externally generated condition.
Which of the following instructions should be privileged?
(a) Set value of timer
(b) Read the clock
(c) Clear memory
(d) Turn off interrupts
(e) Switch from user to monitor mode - answer all but B
[Silberschatz] Protecting the operating system is crucial to ensuring that
the computer system operates correctly. Provision of this protection is the
reason for dual mode operation, memory protection, and the timer. To allow
maximum flexibility, however, you should also place minimal constraints
on the use.
The following is a list of instructions that are normally protected. What is
the minimal set of instructions from this list that must be protected?
(a) Change to user mode
(b) Change to monitor mode
(c) Read from monitor memory
(d) Write into monitor memory
, (e) Fetch an instruction from monitor memory
(f) Turn on timer interrupt
(g) Turn off timer interrupt - answer b,c,d,g, if dont turn off it will run forever
Suppose the hardware interval timer only counts down to zero
before signaling an interrupt. How could an OS use the interval timer to
keep track of the time of day? - answer Have the interval timer reset/restart when the interrupt
fires. It
can do this continually to keep track of time gone by.
Explain the tradeoffs between using multiple processes and using multiple
threads - answer Consider a multiprocess web server application (like from lecture).
Every request creates a new process. This means a new PCB, stack, page
table, etc. Then the OS must schedule this new process before it can
service the request. This involves a context switch. No contrast that with
the same web server written as a multithreaded application. Now just a
TCB needs to be created, a portion of the existing process' stack is used
as the thread's stack, no new page table. Further, the process has control
over which thread to run, and can switch to the most appropriate without a
context switch. However, the main drawback to the multithreaded version
is that the OS doesn't know about all these threads and will not give the
web server more CPU time
Does a multi-threading solution always improve performance? Please explain
your answer and give reasons. - answer Not always. Because the OS doesn't have visibility into
the
threads, it cannot make informed scheduling decisions. It may waste time