CS411/511. Operating Systems
Homework 1 - Solutions
1.1. What are the three main purposes of an operating system?
- To provide a convenient environment for users to execute programs on
computer hardware.
- To allocate, fairly and efficiently, the computer resources needed to
execute the program safely (without adversely affecting other
users or the OS itself).
- To provide a foundation for evolution to future services, while still
supporting existing services.
Note that "convenience," "efficiency," etc. are not acceptable answers,
since they don't explain "convenient/efficient for whom to do what."
1.4. In a multiprogramming and time-sharing environment, several users share the
system simultaneously. This siguation can result in various security problems.
(a) What are two such problems?
(b) Can we ensure the same degree of secutiry in a time-shared machine as we
have in a dedicated machine? Explain your answer.
- Stealing or copying a user's files; writing over another program's
(belonging to another user or to the OS) area in memory;
using system resources (CPU, disk space) without proper accounting;
causing the printer to mix output by sending data while some other user's
file is printing.
- Probably not, since any protection scheme devised by a human can also
be broken -- and the more complex the scheme is, the more difficult
it is to be confident of its correct implementation.
1.6. What are the main differences between operating systems for mainframe
computers and personal computers?
- PC OS's are not concerned with fair use or maximal use of computer
resources. Instead, they try to optimize the usefulness of the
computer for an individual user, usually at the expense of overall
efficiency. Mainframe OS's need more complex scheduling and I/O
algortihms to keep the various system components efficiently
occupied.
1.7. Define the essential properties of the following types of operating
systems:
Batch
Interactive
Time-sharing
Real-time
Distributed
- Batch: Jobs with similar needs are batched together and run
through the computer as a group, by an operator or automatic job sequencer.
Performance is increased by attempting to keep CPU and I/O devices busy at all
times through buffering, off-line operation, spooling, and multiprogramming.
- Interactive: Composed of many short transactions with input
and output read/written on the screen; the results
and timing of the next transaction may be unpredictable. Note that a
purely interactive system (no time-sharing) only has one user; e.g., a PC).
- Time-sharing: Uses CPU scheduling and multiprogramming to provide
economical interactive use of a system. The CPU switches rapidly from one
user to another.
- Real-time: The system must respond to inputs/commands within a
fixed amount of time to ensure correct performance. Input is typically
read from sensors.
- Distributed: Divides computation up among several computers.
The computers do not share memory or a clock; they communicate with each other
over communication lines (e.g., high-speed bus, telephone line).
1.10. Describe the differences between symmetric and asymmetric
multiprocessing. What are three advantages and one disadvantage of
multiprocessor systems?
- Symmetric processing treats all processors as equals; I/O
can be processed on any of them. Asymmetric processing
designates one CPU as the master, which is the only one capable
of performing I/O; the master distributes computational work
among the other CPUs.
- advantages: Multiprocessor systems can save money, by sharing power
supplies, housings, and peripherals. Can execute programs more
quickly and can have increased reliability.
- disadvantages: Multiprocessor systems are more complex in both
hardware and software. Additional CPU cycles are required to
manage the cooperation, so per-CPU efficiency goes down.
2.3. What are the differences between a trap and an interrupt? What is the
use of each function?
- An interrupt is a hardware-generated signal that changes the flow within
the system. A trap is a software-generated interrupt.
- An interrupt can be used to signal the completion of I/O so thatthe
CPU doesn't have to spend cycles polling the device. A trap can be used
to catch arithmetic errors or to call system routines.
2.5. Which of the following instructions should be privileged?
Set value of timer
Read the clock
Clear memory
Turn off interrupts
Switch from user to monitor mode
- Should be privileged.
- Doesn't need to be.
- Should be privileged.
- Should be privileged.
- Should be privileged.
Answer the following questions about policies and mechanisms:
(a) What is an advantage of separating policy from mechanism in
designing any piece of software (including OSs)?
(b) Give three examples of software policies versus mechanisms.
- Clean separation makes systems easier to modify and port. Another answer:
Clearer thinking allowing you to differentiate the desired properties of a
solution from the best solution you've thought of so far. Another answer:
Mechanisms can be changed without affecting the policy.
- Hint: You should always be able to name at least 2 different
mechanisms that could be used to implement a so-called policy.
Some examples:
- policy: share CPU resource fairly among processes. mechanism: timer
interrupts. alternate mechanism: enforce a limit on how long
programs can be.
- policy: some processes are more important or more critical than
others. mechanism: base scheduling upon process priority.
alternate mechanism: force processes to use "nice()" values.
- policy: data values must be kept in order of priority.
mechanism: heap. alternate mechanism: priority-sorted vector.