2019-06-15
23:16:13
1. What are the two main functions of an operating system?
1. An operating system must provide the users with an extended machine, and it must manage the I/O devices and other system resources. To some extent, these are different functions.兩個功能:1.管理資源 2.提供抽象。
在資源管理觀點中,操作系統的任務是有效地管理系統的各個部分。在擴展的機器觀點中,系統的任務是為用戶提供比實際機器更便於運用的抽象。這些抽象包括進程,地址空間以及文件。
2. 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).
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
注意嵌入式操作系統和Handheld(掌上)操作系統的區別:
Sensor-node operating system: Monitoring temperature in a wilderness area
Real-time operating system: Air traffic control system
Smart-card operating system: Electronic payment
3. What is the difference between timesharing and multiprogramming systems?(分時和多道的區別)
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.、
4.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?(cache為什么是按32或64字節讀取,而不是按字節讀取?)
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. (
經驗證據表明,存儲器訪問表現出參考局部性的原理,其中如果讀取一個位置,則接下來訪問附近位置的概率非常高,尤其是以下存儲器位置。
因此,通過緩存整個緩存行,接下來緩存命中的概率會增加。
此外,現代硬件可以將32或64字節的塊傳輸到高速緩存行中,比將單個字讀取相同的數據快得多。)
5. 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?(
5.在早期計算機上,每個讀取或寫入的數據字節都由CPU處理(即
沒有DMA)。
這對多道程序設計有什么影響?
)
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)
多道程序設計的主要原因是在等待I / O完成時為CPU提供一些操作。
如果沒有DMA,則CPU完全占用I / O,因此通過多道程序無法獲得資源(至少在CPU利用率方面)。
無論程序執行多少I / O,CPU都將100%忙碌。
這當然假設主要的延遲是數據被復制時的等待。
如果由於其他原因(例如,到達串行線路)I / O很慢,CPU可以執行其他工作
7. 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?
7. 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.
9. 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 realtime process may get a disproportionate share of the resources.
考慮公平和實時。
公平要求每個流程都以公平的方式分配其資源,沒有任何流程獲得超過其公平份額的流程。
另一方面,實時需要根據不同進程必須完成執行的時間來分配資源。
實時過程可能會獲得不成比例的資源份額。
10. What is the difference between kernel and user mode? Explain how having two distinct modes aids in designing an operating system.
10. 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 ev ery 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.
用戶態可以使用的指令是全部指令的子集。有些關鍵性的指令不能給用戶態使用
11. 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.
11. Number of heads = 255 GB / (65536*255*512) = 16 Number of platters = 16/2 = 8 The time for a read operation to complete is seek time + rotational latency + transfer time. The seek time is 11 ms, the rotational latency is 7 ms and the transfer time is 4 ms, so the average transfer takes 22 msec.
讀取操作完成的時間是尋道時間+旋轉延遲+傳輸時間。
尋道時間為11 ms,旋轉延遲為7 ms,傳輸時間為4 ms,因此平均傳輸時間為22 ms。(讀取速率為100MB/s,題中要求讀取400KB,那么傳輸時間就是4ms)
12. 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.
12. Choices (a), (c), and (d) should be restricted to kernel mode
13. 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.
13. 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.
14. 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?
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.
每一納秒的指令都從管道中出現。
這意味着機器每秒執行10億條指令。
根本沒關系管道有多少個階段。
每級1 nsec的10級流水線每秒也會執行10億條指令。
重要的是一條完成的指令彈出管道末端的頻率。(指令流水暑假時要補一下!)
16. When a user program makes a system call to read or write a disk file, it provides an indication of which file it wants, a pointer to the data buffer, and the count. Control is then transferred to the operating system, which calls the appropriate driver. Suppose that the driver starts the disk and terminates until an interrupt occurs. In the case of reading from the disk, obviously the caller will have to be blocked (because there are no data for it). What about the case of writing to the disk? Need the caller be blocked aw aiting completion of the disk transfer?
17. What is a trap instruction? Explain its use in operating systems.
17. A trap instruction switches the execution mode of a CPU from the user mode to the kernel mode. This instruction allows a user program to invoke functions in the operating system kernel
18. Why is the process table needed in a timesharing system? Is it also needed in personal computer systems running UNIX or Windows with a single user?
The process table is needed to store the state of a process that is currently suspended, either ready or blocked. Modern personal computer systems have dozens of processes running even when the user is doing nothing and no programs are open. They are checking for updates, loading email, and many other things, On a UNIX system, use the ps -a command to see them. On a Windows system, use the task manager.
需要進程表來存儲當前掛起的進程的狀態,無論是就緒還是阻止。
現代個人計算機系統即使在用戶什么都不做而且沒有打開程序的情況下也有許多進程在運行。
他們正在檢查更新,加載電子郵件和許多其他事情,在UNIX系統上,使用ps -a命令查看它們。
在Windows系統上,使用任務管理器。
19. Is there any reason why you might want to mount a file system on a nonempty directory? If so, what is it?(在非空的目錄上裝文件系統)
Mounting a file system makes any files already in the mount-point directory inaccessible, so mount points are normally empty. Howev er, 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 repaired.
安裝文件系統會使安裝點目錄中的任何文件無法訪問,因此安裝點通常為空。
但是,系統管理員可能希望將通常位於安裝目錄中的一些最重要的文件復制到安裝點,以便在安裝設備修復時可以在緊急情況下找到它們的正常路徑。
20. For each of the following system calls, give a condition that causes it to fail: fork, exec, and unlink.
20. 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
21. What type of multiplexing (time, space, or both) can be used for sharing the following resources: CPU, memory, disk, network card, printer, keyboard, and display?