Unit 1 - Exercise - Solution
Unit 1 - Exercise - Solution
Unit 1 - Exercise - Solution
CHAPTER
Introduction
Practice Exercises
1.1 What are the three main purposes of an operating system?
Answer:
The three main puropses are:
1.2 We have stressed the need for an operating system to make efficient use
of the computing hardware. When is it appropriate for the operating
system to forsake this principle and to “waste” resources? Why is such
a system not really wasteful?
Answer:
Single-user systems should maximize use of the system for the user. A
GUI might “waste” CPU cycles, but it optimizes the user’s interaction
with the system.
1.3 What is the main difficulty that a programmer must overcome in writing
an operating system for a real-time environment?
Answer:
The main difficulty is keeping the operating system within the fixed time
constraints of a real-time system. If the system does not complete a task
in a certain time frame, it may cause a breakdown of the entire system it
is running. Therefore when writing an operating system for a real-time
system, the writer must be sure that his scheduling schemes don’t allow
response time to exceed the time constraint.
1
2 Chapter 1 Introduction
retain data as well), and (b) the cache is affordable, because faster storage
tends to be more expensive.
1.11 Distinguish between the client–server and peer-to-peer models of
distributed systems.
Answer:
The client-server model firmly distinguishes the roles of the client and
server. Under this model, the client requests services that are provided
by the server. The peer-to-peer model doesn’t have such strict roles. In
fact, all nodes in the system are considered peers and thus may act as
either clients or servers—or both. A node may request a service from
another peer, or the node may in fact provide such a service to other
peers in the system.
For example, let’s consider a system of nodes that share cooking
recipes. Under the client-server model, all recipes are stored with the
server. If a client wishes to access a recipe, it must request the recipe from
the specified server. Using the peer-to-peer model, a peer node could ask
other peer nodes for the specified recipe. The node (or perhaps nodes)
with the requested recipe could provide it to the requesting node. Notice
how each peer may act as both a client (it may request recipes) and as a
server (it may provide recipes).
Operating-
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 operat-
ing 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
memory 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:
5
6 Chapter 2 Operating-System Structures
• Free-space management.
• Storage allocation.
• Disk scheduling.
should have access to and to access them only when they are
otherwise unused.
c. File-system manipulation. There are many details in file creation,
deletion, allocation, and naming that users should not have to
perform. Blocks of disk space are used by files and must be tracked.
Deleting a file requires removing the name file information and
freeing the allocated blocks. Protections must also be checked
to assure proper file access. User programs could neither ensure
adherence to protection methods nor be trusted to allocate only
free blocks and deallocate blocks on file deletion.
d. Communications. Message passing between systems requires
messages to be turned into packets of information, sent to the
network controller, transmitted across a communications medium,
and reassembled by the destination system. Packet ordering and
data correction must take place. Again, user programs might not
coordinate access to the network device, or they might receive
packets destined for other processes.
e. Error detection. Error detection occurs at both the hardware and
software levels. At the hardware level, all data transfers must be
inspected to ensure that data have not been corrupted in transit. All
data on media must be checked to be sure they have not changed
since they were written to the media. At the software level, media
must be checked for data consistency; for instance, whether the
number of allocated and unallocated blocks of storage match the
total number on the device. There, errors are frequently process-
independent (for instance, the corruption of data on a disk), so there
must be a global program (the operating system) that handles all
types of errors. Also, by having errors processed by the operating
system, processes need not contain code to catch and correct all the
errors possible on a system.
2.10 Why do some systems store the operating system in firmware, while
others store it on disk?
Answer:
For certain devices, such as handheld PDAs and cellular telephones, a
disk with a file system may be not be available for the device. In this
situation, the operating system must be stored in firmware.
2.11 How could a system be designed to allow a choice of operating systems
from which to boot? What would the bootstrap program need to do?
Answer:
Consider a system that would like to run both Windows XP and three
different distributions of Linux (e.g., RedHat, Debian, and Mandrake).
Each operating system will be stored on disk. During system boot-up, a
special program (which we will call the boot manager) will determine
which operating system to boot into. This means that rather initially
booting to an operating system, the boot manager will first run during
system startup. It is this boot manager that is responsible for determining
which system to boot into. Typically boot managers must be stored at
8 Chapter 2 Operating-System Structures