You are on page 1of 2

Answers to Midterm Exam.

of Operating Systems
2005/11/08 (Tue.)

1.

What is a process? Can a process exist only in memory? Explain your answer. (10%)
) A process is a program in execution. (5%)
No. (2%)
A process could be removed from memory and stored on disk. Later, the process can be
introduced into memory. This scheme is called swapping. (3%)

2.

What is the degree of multiprogramming? Which scheduler controls the degree of


multiprogramming? And whats its decision policy? (10%)
) The degree of multiprogramming is the number of processes in memory. (5%)
The long-term scheduler (or job scheduler) controls the degree of multiprogramming (2%) by
selecting a good process mix of I/O-bound and CPU-bound processes. (3%)

3.

What is the main advantage of the microkernel approach to system design? (10%)
) (1) Easy to extend the operating system: adding a new service does not require modifying the
kernel (3%)
(2) Easy to port from one hardware design to another (3%)
(3) More security and reliability (2%, 2%)

4.

What are the differences between a trap and an interrupt? What is the use of each function?
(10%)
) An interrupt is a hardware-generated change-of-flow within the system. An interrupt handler is
summoned to deal with the cause of the interrupt; control is then returned to the interrupted
context and instruction. (4%)
A trap is a software-generated interrupt. (2%)
An interrupt can be used to signal the completion of an I/O to obviate the need for device
pooling. (2%)
A trap can be used to call operating system routines or to catch arithmetic errors. (2%)

5.

What is the purpose of the command interpreter? Why is it usually separate from the kernel?
(10%)
) It reads commands from the user or from a file of commands and executes them, usually by
turning them into one or more system calls. (5%)
It is usually not part of the kernel since the command interpreter is subject to changes. (5%)

6.

What are the two models of interprocess communication? What are the strengths and
weakness of the two approaches? (10%)
) The two models of interprocess communication are message passing model and the
1

shared-memory model. (4%)


Message passing is useful for exchanging smaller amounts of data and also easier to
implement. Shared memory allows maximum speed and convenience of communication, while
message passing requires the more time-consuming task of kernel intervention. Shared memory
also has problems of protection and synchronization. (6%)
7.

Describe the actions taken by a kernel to switch context between processes. (10%)
) In general, the operating system must save the state of the currently running process and
restore the state of the process scheduled to be run next. Saving the state of a process
typically includes the values of all the CPU registers in addition to memory allocation. Context
switches must also perform many architecture-specific operations, including flushing data and
instruction caches.

8.

The CPU is allowed to execute other programs while the DMA controller is transferring data.
Does this interfere with the execution of the user programs? If so, describe what forms of
interference are caused. (10%)
) Yes. (2%)
Both the device and the CPU can be accessing memory simultaneously. The memory controller
provides access to the memory bus in a fair manner to these two entities. A CPU might therefore
be unable to issue memory operations at peak speeds since it has to compete with the device in
order to obtain access to the memory bus. (8%)

9.

What is the main advantage for an operating-system designer of using a virtual-machine


architecture? What is the main advantage for a user? (10%)
) The system is easy to debug, and security problems are easy to solve. (3%, 3%)
Virtual machines also provide a good platform for operating system research since many
different operating systems may run on one physical system. (4%)

10. Why is a just-in-time(JIT) compiler useful for executing Java programs? (10%)
)

Java is an interpreted language. This means that the JVM interprets the byte-code instructions
one at a time. Typically, most interpreted environments are slower than running native binaries,
for the interpretation process requires converting each instruction into native machine code. A
just-in-time(JIT) compiler compiles the bytecode for a method into native machine code the
first time the method is encountered. This means that the Java program is essentially running a
native application (of course, the conversion process of the JIT takes time as well but not as
much as bytecode interpretation.) Furthermore, the JIT caches compiled code so that it may be
reused the next time the method is encountered. A Java program that is run by a JIT rather a
traditional interpreter typically runs much faster.

You might also like