Chapter 14 - UNIX Internals
Quiz
1. Why does the kernel maintain multiple priority queues?
- Multiple priority queues are associated with different process priority
levels.
2. Why do system calls make use of kernel mode?
- Since system calls manipulate kernel data structures, they must run
in kernel mode as kernel data structures are protected from processes
running in user mode.
3. What happens when an interrupt interrupts another interrupt?
- If the new interrupt has a higher priority than the interrupt currently
being processed, then the current interrupt it itself interrupted and
the higher interrupt is processed. If the new interrupt has an equal
or lower priority, it is discarded (i.e. lost).
4. How do modern disk designs attempt to increase total storage capacity?
- Modern disks increase storage capacity by minimizing the waste of
space that occurred in the outer tracks of traditional disk drives.
When disk rotation speed is constant, blocks in the outer tracks use
more surface area because the head passes over more area in a given
amount of time than in the inner tracks. The same amount of data is
stored in a larger physical area than in blocks in the inner blocks.
Newer disk drives adjust rotational speeds or data transfer rates to
maintain the same density of data on all tracks of a disk. This allows
more blocks to be stored in each track as you move outward from the
center of the disk).
5. Where is the name of a file stored?
- Filenames are stored in the directory file with which they are associated.
6. What information does the superblock contain?
- The superblock contains information about blocks and inodes in a
file system. This includes the number and size of disk blocks and how
many are available for use as well as the number of available inodes
in the file system.
7. How does UNIX avoid using bad blocks?
- Bad blocks are allocated to a special file whose only purpose is
to keep them from being accessible to any other regular file.
8. Why is inode #2 special?
- This inode is used for the root directory of the file system.
9. What is the meaning of the term magic number?
- The numeric value of the first few bytes of a file is its magic number.
Most UNIX files of special formats (executables, shell scripts, etc.)
contain specific values in the first few bytes (the number of bytes
used may vary depending on the format). UNIX utilities (such as file)
can make use of this information to identify the file type.
10. What is the meaning of the term context switch?
- A context switch takes place when the process scheduler swaps out
a running process and swaps in a different process to be executed.
11. What information is stored in a processís user area?
- Housekeeping information is stored in the user area of a process.
This includes mappings between signals and reactions the process will
have to them (the signal handler array), a list of open file descriptors,
and the amount of CPU time the process has used recently.
12. If a signal is sent to a process that is suspended, where is the signal
stored?
- When a suspended process receives a signal, the kernel sets the appropriate
bit in the pending signal bitmap in the process table.
13. Describe an overview of the memory mapping that the MMU performs.
- Very simply, the MMU maps pages of virtual memory into physical memory
space and manages the swapping in and out of pages as they are required
by running processes.
14. What does the page daemon do?
- The page daemon is the process that actually swaps pages of virtual
memory in and out of physical memory as requested by the MMU.
15. How does UNIX copy a parentís data to its child?
- The child gets a pointer to the parentís data region and the copy-on-write
bit is set. If the child process deallocates the data space, no copy
is necessary. Only when the child modifies the data is a separate copy
created for the child.
16. What is the meaning of the term ìdelayed writeî?
- Delayed write is the term used to describe the method the UNIX kernel
uses to write disk blocks back out to the physical media. The kernel
keeps the data buffered so that multiple writes do not require multiple
disk accesses. The block is only written when its buffer needs to be
removed from the buffer pool.
17. What is the purpose of the open file table?
- The open file table provides a way for the kernel to manage processesí
open files and keep up with the current positions in the files where
each process is reading or writing.
18. What is the use of the I/O switch tables?
- Device drivers use the switch table to determine which of several
similar devices should be accessed.
19. Why does the UNIX terminal driver use clists?
- C-lists are used to buffer TTY input and output for the terminal
driver.
20. What is the main implementation difference between BSD and System V
pipes?
- The major difference is System V (Release 4) pipes are implemented
with STREAMS and BSD pipes are implemented with sockets.
Exercises
14.1 Using ps, find the process on the system with the lowest process
ID (PID). What is the process and why does it have this PID? [level: easy]
- Depending on your version of UNIX, the program running as PID 0 should
be swapper or sched. Memory management and process scheduling
are some of the first things that must occur as the operating system
starts up. UNIX begins assigning PIDs with 0, so this will be the first
process that was started.
14.2 The superblock contains a lot of important information. Suggest some
ways to minimize disruption to the file system in the case the superblock
gets corrupted. [level: medium]
- Most versions of UNIX make multiple copies of the superblock in different
areas of the disk. If the superblock is corrupted, another copy of it
should be accessible.
14.3 When very small files are created, some disk space is lost due to the
minimum allocation unit size. This wasted space is called internal fragmentation.
Suggest some ways to minimize internal fragmentation. [level: medium]
- One way might be to gather the last fragments of many files and put
them together into one file so that only that new file has a fragment.
Of course, the overhead to do this and keep up with it would increase
the time required to read and write files in the file system.
14.4 Delayed writing normally causes a modified buffer to be flushed when
its RAM is needed, not when its file is closed. An alternative method is
to flush modified buffers when disk traffic is low, thereby making the best
use of the idle time. Critique this strategy. [level: medium]
- There is no right answer. Depending on the environment, either method
could be more advantageous. To be able to compare the strategies, the
student will have an understanding of the differences between them.
14.5 A low-priority interrupt may be lost if it occurs during the servicing
of a higher priority interrupt. How do you think the systemís software
deals with lost interrupts? [level: hard]
- Perhaps it doesnít. In reality, this is why code that processes interrupts
should be as fast as possible, to minimize the window where a lower
priority interrupt could be lost. In some cases, lower priority interrupts
may represent conditions that will persist and generate more interrupts,
so the loss may not be significant.
Projects
1. Investigate some other operating systems, such as Mach, Plan 9, and Windows
NT. How do they compare with UNIX? [level: medium]
- There are many answers to this, but the act of investigation and
discussion is the value.
2. If you know object-oriented techniques, design a basic object-oriented
kernel that provides system services by a collection of system objects.
How does the design of your kernel differ from that of the UNIX kernel?
[level: hard]
- AT&Tís Plan 9 operating system might provide some insight into
a discussion of this topic.
|