Op 2
Op 2
Op 2
System
2
CHAPTER
Structures
Practice Exercises
2.1 What is the purpose of system calls?
Answer: System calls allow user-level processes to request services of
the operating system.
2.2 What are the five major activities of an operating system with regard to
process management?
Answer: The five major activities are:
a. The creation and deletion of both user and system processes
b. The suspension and resumption of processes
c. The provision of mechanisms for process synchronization
d. The provision of mechanisms for process communication
e. The provision of mechanisms for deadlock handling
2.3 What are the three major activities of an operating system with regard
to memory management?
Answer: The three major activities are:
a. Keep track of which parts of memory are currently being used and
by whom.
b. Decide which processes are to be loaded into memory when mem-
ory space becomes available.
c. Allocate and deallocate memory space as needed.
2.4 What are the three major activities of an operating system with regard
to secondary-storage management?
Answer: The three major activities are:
• Free-space management.
• Storage allocation.
• Disk scheduling.
5
6 Chapter 2 Operating-System Structures
2.13 Describe three general methods for passing parameters to the operating system.
Answer:
a. Pass parameters in registers
b. Registers pass starting addresses of blocks of parameters
c. Parameters can be placed, or pushed, onto the stack by the program, and popped off
the stack by the operating system.
2.14 Describe how you could obtain a statistical profile of the amount of time spent by
a program executing different sections of its code. Discuss the importance of obtaining
such a statistical profile.
Answer: One could issue periodic timer interrupts and monitor what instructions or
what sections of code are currently executing when the interrupts are delivered. A
statistical profile of which pieces of code were active should be consistent with the
time spent by the program in different sections of its code. Once such a statistical
profile has been obtained, the programmer could optimize those sections of code that
are consuming more of the CPU resources.
2.15 What are the five major activities of an operating system in regard to file
management?
Answer:
• The creation and deletion of files
• The creation and deletion of directories
• The support of primitives for manipulating files and directories
• The mapping of files onto secondary storage
• The backup of files on stable (nonvolatile) storage media
2.16 What are the advantages and disadvantages of using the same system call
interface for manipulating both files and devices?
Answer: Each device can be accessed as though it was a file in the file system. Since
most of the kernel deals with devices through this file interface, it is relatively easy to
add a new device driver by implementing the hardware-specific code to support this
abstract file interface. Therefore, this benefits the development of both user program
code, which can be written to access devices and files in the same manner, and device
driver code, which can be written to support a well-defined API. The disadvantage
with using the same interface is that it might be difficult to capture the functionality of
certain devices within the context of the file access API, thereby either resulting in a
loss of functionality or a loss of performance. Some of this could be overcome by the
use of ioctl operation that provides a general purpose interface for processes to invoke
operations on devices.
2.18 What are the two models of interprocess communication? What are the
strengths and weaknesses of the two approaches?
Answer: The two models of interprocess communication are message passing
model and the shared-memory model. The message-passing model controls the
2.21 What is the main advantage of the microkernel approach to system design? How
do user programs and system services interact in a microkernel architecture? What are
the disadvantages of using the microkernel approach?
Answer: Benefits typically include the following (a) adding a new service does not
require modifying the kernel, (b) it is more secure as more operations are done in user
mode than in kernel mode, and (c) a simpler kernel design and functionality typically
results in a more reliable operating system. User programs and system services interact
in a microkernel architecture by using interprocess communication mechanisms such
asmessaging. These messages are conveyed by the operating system. The primary
disadvantage of the microkernel architecture are the overheads associated with
interprocess communication and the frequent use of the operating system’s messaging
functions in order to enable the user process and the system service to interact with
each other.
2.22 In what ways is the modular kernel approach similar to the layered approach? In
what ways does it differ from the layered approach?
Answer: The modular kernel approach requires subsystems to interact with each other
through carefully constructed interfaces that are typically narrow (in terms of the
functionality that is exposed to external modules). The layered kernel approach is
similar in that respect. However, the layered kernel imposes a strict ordering of
subsystems such that subsystems at the lower layers are not allowed to invoke
operations corresponding to the upper-layer subsystems. There are no such restrictions
in the modular-kernel approach, wherein modules are free to invoke each other
without any constraints.
2.23 What is the main advantage for an operating-system designer of using virtual-
machine architecture? What is the main advantage for a user?
Answer: The system is easy to debug, and security problems are easy to solve. Virtual
machines also provide a good platform for operating system research since many
different operating systems may run on one physical system.
2.24 Why is a just-in-time compiler useful for executing Java programs?
Answer: Java is an interpreted language. This means that the JVM interprets the
bytecode 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 as 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 than a traditional interpreter typically runs much faster.
2.25 What is the relationship between a guest operating system and a host operating
system in a system like VMware? What factors need to be considered in choosing the
host operating system?
Answer: A guest operating system provides its services by mapping them onto the
functionality provided by the host operating system. A key issue that needs to be
considered in choosing the host operating system is whether it is sufficiently general in
terms of its system-call interface in order to be able to support the functionality
associated with the guest operating system.