Introduction Flashcards
What are the two main functions of an operating system?
(HW1)
An operating system must provide the users with an extended machine, and it must manage the I/O devices and other system resources.
In Section 1.4, nine different types of operating systems are described. Give a list of applications for each of these systems (one per operating systems type).
(HW1)
Obviously, there are a lot of possible answers. Here are some.
• Mainframe operating system: Claims processing in an insurance company.
• Server operating system: Speech-to-text conversion service for Siri.
• Multiprocessor operating system: Video editing and rendering.
• Personal computer operating system: Word processing application.
• Handheld computer operating system: Context-aware recommendation system.
• Embedded operating system: Programming a DVD recorder for recording TV.
• Sensor-node operating system: Monitoring temperature in a wilderness area.
• Real-time operating system: Air traffic control system.
• Smart-card operating system: Electronic payment.
What is the difference between timesharing and multiprogramming systems?
(HW1)
In a timesharing system, multiple users can access and perform computations on a computing system simultaneously using their own terminals. Multiprogramming systems allow a user to run multiple programs simultaneously. All timesharing systems are multiprogramming systems but not all multiprogramming systems are timesharing systems since a multiprogramming system may run on a PC with only one user.
To use cache memory, main memory is divided into cache lines, typically 32 or 64 bytes
long. An entire cache line is cached at once. What is the advantage of caching an entire line
instead of a single byte or word at a time?
(HW1)
Empirical evidence shows that memory access exhibits the principle of locality of reference,
where if one location is read then the probability of accessing nearby locations next is very high,
particularly the following memory locations. So, by caching an entire cache line, the probability of a cache hit next is increased. Also, modern hardware can do a block transfer of 32 or 64 bytes
into a cache line much faster than reading the same data as individual words.
On early computers, every byte of data read or written was handled by the CPU (i.e., there
was no DMA). What implications does this have for multiprogramming?
The prime reason for multiprogramming is to give the CPU something to do while waiting for I/O
to complete. If there is no DMA, the CPU is fully occupied doing I/O, so there is nothing to be
gained (at least in terms of CPU utilization) by multiprogramming. No matter how much I/O a
program does, the CPU will be 100% busy. This of course assumes the major delay is the wait
while data are copied. A CPU could do other work if the I/O were slow for other reasons
(arriving on a serial line, for instance).
Instructions related to accessing I/O devices are typically privileged instructions, that is,
they can be executed in kernel mode but not in user mode. Give a reason why these
instructions are privileged.
Access to I/O devices (e.g., a printer) is typically restricted for different users. Some users may
be allowed to print as many pages as they like, some users may not be allowed to print at all,
while some users may be limited to printing only a certain number of pages. These restrictions
are set by system administrators based on some policies. Such policies need to be enforced so
that user-level programs cannot interfere with them.
The family-of-computers idea was introduced in the 1960s with the IBM System/360
mainframes. Is this idea now dead as a doornail or does it live on?
It is still alive. For example, Intel makes Core i3, i5, and i7 CPUs with a variety of different
properties including speed and power consumption. All of these machines are architecturally
compatible. They differ only in price and performance, which is the essence of the family idea.
One reason GUIs were initially slow to be adopted was the cost of the hardware needed to
support them. How much video RAM is needed to support a 25-line × 80-row character
monochrome text screen? How much for a 1200 × 900-pixel 24-bit color bitmap? What was
the cost of this RAM at 1980 prices ($5/KB)? How much is it now?
(TUT1)
A 25 × 80 character monochrome text screen requires a 2000-byte buffer. The 1200 × 900 pixel
24-bit color bitmap requires 3,240,000 bytes. In 1980 these two options would have cost $10
and $15,820, respectively. For current prices, check on how much RAM currently costs, probably
pennies per MB.
There are several design goals in building an operating system, for example, resource
utilization, timeliness, robustness, and so on. Give an example of two design goals that may
contradict one another.
Consider fairness and real time. Fairness requires that each process be allocated its resources in
a fair way, with no process getting more than its fair share. On the other hand, real time
requires that resources be allocated based on the times when different processes must
complete their execution. A real-time process may get a disproportionate share of the
resources.
What is the difference between kernel and user mode? Explain how having two distinct
modes aids in designing an operating system.
(HW1)
Most modern CPUs provide two modes of execution: kernel mode and user mode. The CPU can
execute every instruction in its instruction set and use every feature of the hardware when
executing in kernel mode. However, it can execute only a subset of instructions and use only
subset of features when executing in the user mode. Having two modes allows designers to run
user programs in user mode and thus deny them access to critical instructions.
A 255-GB disk has 65,536 cylinders with 255 sectors per track and 512 bytes per sector.
How many platters and heads does this disk have? Assuming an average cylinder seek time of
11 ms, average rotational delay of 7 msec and reading rate of 100 MB/sec, calculate the
average time it will take to read 400 KB from one sector.
Capacity of disk = (cylinders/disk) × (sectors/track) × (heads/cylinder) × (bytes/sector)
Number of heads = 255 GB / (65536255512) = 32
Number of platters = 32 / 2 = 16
Access time = seek time + rotational delay + transfer rate
The transfer time = 400 KB / 100 MB/s ≈ 4msec
The amount of time taken to read 400KB = 11 + 7 + 4 = 22 msec
Which of the following instructions should be allowed only in kernel mode?
a) Disable all interrupts.
b) Read the time-of-day clock.
c) Set the time-of-day clock.
d) Change the memory map.
(HW1)
a) Disable all interrupts.
c) Set the time-of-day clock.
d) Change the memory map.
Consider a system that has two CPUs, each CPU having two threads (hyperthreading).
Suppose three programs, P0, P1, and P2, are started with run times of 5, 10 and 20 msec,
respectively. How long will it take to complete the execution of these programs? Assume that
all three programs are 100% CPU bound, do not block during execution, and do not change
CPUs once assigned.
(HW1)
It may take 20, 25 or 30 msec to complete the execution of these programs depending on how
the operating system schedules them. If P0 and P1 are scheduled on the same CPU and P2 is
scheduled on the other CPU, it will take 20 msec. If P0 and P2 are scheduled on the same CPU
and P1 is scheduled on the other CPU, it will take 25 msec. If P1 and P2 are scheduled on the
same CPU and P0 is scheduled on the other CPU, it will take 30 msec. If all three are on the
same CPU, it will take 35 msec.
A computer has a pipeline with four stages. Each stage takes the same time to do its work,
namely, 1 nsec. How many instructions per second can this machine execute?
(HW1)
Every nanosecond one instruction emerges from the pipeline. This means the machine is
executing 1 billion instructions per second. It does not matter at all how many stages the
pipeline has. A 10-stage pipeline with 1 nsec per stage would also execute 1 billion instructions
per second. All that matters is how often a finished instruction pops out the end of the pipeline.
Consider a computer system that has cache memory, main memory (RAM) and disk, and
an operating system that uses virtual memory. It takes 1 nsec to access a word from the
cache, 10 nsec to access a word from the RAM, and 10 ms to access a word from the disk. If
the cache hit rate is 95% and main memory hit rate (after a cache miss) is 99%, what is the
average time to access a word?
(HW1)
Average access time =
0.95 × 1 nsec (word is in the cache)
+ 0.05 × 0.99 × 10 nsec (word is in RAM, but not in the cache)
+ 0.05 × 0.01 × 10,000,000 nsec (word on disk only)
= 5001.445 nsec
= 5.001445 μsec