没有合适的资源?快使用搜索试试~ 我知道了~
现代操作系统答案 现代操作系英文版答案
需积分: 48 7 下载量 182 浏览量
2009-09-22
19:53:17
上传
评论
收藏 206KB PDF 举报
温馨提示
试读
60页
现代操作系英文版答案现代操作系英文版答案现代操作系英文版答案现代操作系英文版答案现代操作系英文版答案现代操作系英文版答案
资源推荐
资源详情
资源评论
MODERN
OPERATING
SYSTEMS
SECOND EDITION
PROBLEM SOLUTIONS
ANDREW S. TANENBAUM
Vrije Universiteit
Amsterdam, The Netherlands
PRENTICE HALL
UPPER SADDLE RIVER, NJ 07458
SOLUTIONS TO CHAPTER 1 PROBLEMS
1. An operating system must provide the users with an extended (i.e., virtual)
machine, and it must manage the I/O devices and other system resources.
2. Multiprogramming is the rapid switching of the CPU between multiple
processes in memory. It is commonly used to keep the CPU busy while one
or more processes are doing I/O.
3. Input spooling is the technique of reading in jobs, for example, from cards,
onto the disk, so that when the currently executing processes are finished,
there will be work waiting for the CPU. Output spooling consists of first
copying printable files to disk before printing them, rather than printing
directly as the output is generated. Input spooling on a personal computer is
not very likely, but output spooling is.
4. 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 occu-
pied doing I/O, so there is nothing to be gained (at least in terms of CPU utili-
zation) by multiprogramming. No matter how much I/O a program does, the
CPU will be 100 percent 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).
5. Second generation computers did not have the necessary hardware to protect
the operating system from malicious user programs.
6. It is still alive. For example, Intel makes Pentium I, II, and III, and 4 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.
7. A25× 80 character monochrome text screen requires a 2000-byte buffer. The
1024 × 768 pixel 24-bit color bitmap requires 2,359,296 bytes. In 1980 these
two options would have cost $10 and $11,520, respectively. For current
prices, check on how much RAM currently costs, probably less than $1/MB.
8. Choices (a), (c), and (d) should be restricted to kernel mode.
9. Personal computer systems are always interactive, often with only a single
user. Mainframe systems nearly always emphasize batch or timesharing with
many users. Protection is much more of an issue on mainframe systems, as is
efficient use of all resources.
10. 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
2 PROBLEM SOLUTIONS FOR CHAPTER 1
stage would also execute 1 billion instructions per second. All that matters is
how often a finished instructions pops out the end of the pipeline.
11. The manuscript contains 80 × 50 × 700 = 2.8 million characters. This is, of
course, impossible to fit into the registers of any currently available CPU and
is too big for a 1-MB cache, but if such hardware were available, the
manuscript could be scanned in 2.8 msec from the registers or 5.8 msec from
the cache. There are approximately 2700 1024-byte blocks of data, so scan-
ning from the disk would require about 27 seconds, and from tape 2 minutes 7
seconds. Of course, these times are just to read the data. Processing and
rewriting the data would increase the time.
12. Logically, it does not matter if the limit register uses a virtual address or a
physical address. However, the performance of the former is better. If virtual
addresses are used, the addition of the virtual address and the base register
can start simultaneously with the comparison and then can run in parallel. If
physical addresses are used, the comparison cannot start until the addition is
complete, increasing the access time.
13. Maybe. If the caller gets control back and immediately overwrites the data,
when the write finally occurs, the wrong data will be written. However, if the
driver first copies the data to a private buffer before returning, then the caller
can be allowed to continue immediately. Another possibility is to allow the
caller to continue and give it a signal when the buffer may be reused, but this
is tricky and error prone.
14. A trap is caused by the program and is synchronous with it. If the program is
run again and again, the trap will always occur at exactly the same position in
the instruction stream. An interrupt is caused by an external event and its
timing is not reproducible.
15. Base = 40,000 and limit = 10,000. An answer of limit = 50,000 is incorrect
for the way the system was described in this book. It could have been imple-
mented that way, but doing so would have required waiting until the address
+ base calculation was completed before starting the limit check, thus slow-
ing down the computer.
16. The process table is needed to store the state of a process that is currently
suspended, either ready or blocked. It is not needed in a single process sys-
tem because the single process is never suspended.
17. Mounting a file system makes any files already in the mount point directory
inaccessible, so mount points are normally empty. However, a system
administrator might want to copy some of the most important files normally
located in the mounted directory to the mount point so they could be found in
their normal path in an emergency when the mounted device was being
checked or repaired.
PROBLEM SOLUTIONS FOR CHAPTER 1 3
18. Fork can fail if there are no free slots left in the process table (and possibly if
there is no memory or swap space left).
Exec can fail if the file name given
does not exist or is not a valid executable file.
Unlink can fail if the file to be
unlinked does not exist or the calling process does not have the authority to
unlink it.
19. If the call fails, for example because fd is incorrect, it can return −1. It can
also fail because the disk is full and it is not possible to write the number of
bytes requested. On a correct termination, it always returns nbytes.
20. It contains the bytes: 1, 5, 9, 2.
21. Block special files consist of numbered blocks, each of which can be read or
written independently of all the other ones. It is possible to seek to any block
and start reading or writing. This is not possible with character special files.
22. System calls do not really have names, other than in a documentation sense.
When the library procedure read traps to the kernel, it puts the number of the
system call in a register or on the stack. This number is used to index into a
table. There is really no name used anywhere. On the other hand, the name
of the library procedure is very important, since that is what appears in the
program.
23. Yes it can, especially if the kernel is a message-passing system.
24. As far as program logic is concerned it does not matter whether a call to a
library procedure results in a system call. But if performance is an issue, if a
task can be accomplished without a system call the program will run faster.
Every system call involves overhead time in switching from the user context
to the kernel context. Furthermore, on a multiuser system the operating sys-
tem may schedule another process to run when a system call completes,
further slowing the progress in real time of a calling process.
25. Several
UNIX calls have no counterpart in the Win32 API:
Link: a Win32 program cannot refer to a file by an alternate name or see it in
more than one directory. Also, attempting to create a link is a convenient way
to test for and create a lock on a file.
Mount and umount: a Windows program cannot make assumptions about
standard path names because on systems with multiple disk drives the drive
name part of the path may be different.
Chmod: Windows programmers have to assume that every user can access
every file.
Kill: Windows programmers cannot kill a misbehaving program that is not
cooperating.
4 PROBLEM SOLUTIONS FOR CHAPTER 1
26. The conversions are straightforward:
(a) A micro year is 10
−6
× 365 × 24 × 3600 = 31.536 sec.
(b) 1000 meters or 1 km.
(c) There are 2
40
bytes, which is 1,099,511,627,776 bytes.
(d) It is 6 × 10
24
kg.
SOLUTIONS TO CHAPTER 2 PROBLEMS
1. The transition from blocked to running is conceivable. Suppose that a proc-
ess is blocked on I/O and the I/O finishes. If the CPU is otherwise idle, the
process could go directly from blocked to running. The other missing transi-
tion, from ready to blocked, is impossible. A ready process cannot do I/O or
anything else that might block it. Only a running process can block.
2. You could have a register containing a pointer to the current process table
entry. When I/O completed, the CPU would store the current machine state
in the current process table entry. Then it would go to the interrupt vector for
the interrupting device and fetch a pointer to another process table entry (the
service procedure). This process would then be started up.
3. Generally, high-level languages do not allow one the kind of access to CPU
hardware that is required. For instance, an interrupt handler may be required
to enable and disable the interrupt servicing a particular device, or to manipu-
late data within a process’ stack area. Also, interrupt service routines must
execute as rapidly as possible.
4. There are several reasons for using a separate stack for the kernel. Two of
them are as follows. First, you do not want the operating system to crash
because a poorly written user program does not allow for enough stack space.
Second, if the kernel leaves stack data in a user program’s memory space
upon return from a system call, a malicious user might be able to use this data
to find out information about other processes.
5. It would be difficult, if not impossible, to keep the file system consistent.
Suppose that a client process sends a request to server process 1 to update a
file. This process updates the cache entry in its memory. Shortly thereafter,
another client process sends a request to server 2 to read that file. Unfor-
tunately, if the file is also cached there, server 2, in its innocence, will return
obsolete data. If the first process writes the file through to the disk after cach-
ing it, and server 2 checks the disk on every read to see if its cached copy is
up-to-date, the system can be made to work, but it is precisely all these disk
accesses that the caching system is trying to avoid.
剩余59页未读,继续阅读
资源评论
wowoshen
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于MQTT的智能宠物投喂系统
- 312749069629470selfieU重绘.apk
- http%3A%2F%2Fimg.wsdl.vivo.com.cn%2Fappstore%2Fdeveloper%2Ficon%2F201412%2F201412231038336
- 主要记录B站up主莫烦matplotlib教程中的代码.zip
- Java SE Development Kit 8u411 Windows x64 Installer
- 用于科学绘图的 Matplotlib 样式.zip
- Java SE Development Kit 11.0.23 Windows x64 Installer
- 毕业设计-后端项目-网站民宿展示网站SSM
- 基于python绘图,程序详细展示了绘图过程中详尽的命令语句,使得图片达到可发表程度 .zip
- Java SE Development Kit 11.0.23 macOS x64 DMG Installer
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功