前言:关于 CS162课程 与 Operating Systems Principles and Practice教材
1. What is an example of an operating system as:
a. Referee?
b. Illusionist?
c. Glue?
a:
Referee = Resource Sharing Control
Resource allocation: For example, an operating system can stop one program and start another (processor slice). And since the applications share physical resources, the operating system needs to decide which applications get which resources and when.
Isolation: For example, an error(bug) caused by one application won't corrupt other applications/users running on the same machine, because operating system isolates them from each other.
Communication: For example, a web site may be implemented by a cooperating set of applications: one to select advertisements, another to cache recent results, yet another to fetch and merge data from disk, and several more to cooperatively scan the web for new content to index. For this to work, the various programs must need help of operating system to communicate with one another.
b:
Illusion = Virtualization
For example, wireless networks drop or corrupt packets; the operating system masks these failures to provide the illusion of a reliable service.
c:
Glue = Providing Common and Standard Services
For example, the web server is able to read the file that the text editor wrote, because they both use the standard I/O services provided by operating system.
2. What is the difference, if any, between the following terms:
a. Reliability vs. availability?
b. Security vs. privacy?
c. Security enforcement vs. security policy?
d. Throughput vs. response time?
e. Efficiency vs. overhead?
f. Application programming interface (API) vs. abstract virtual machine (AVM)?
g. Abstract virtual machine (AVM) vs. hardware abstraction layer (HAL)?
h. Proprietary vs. open operating system?
i. Batch vs. interactive operating system?
j. Host vs. guest operating system?
a:
Reliability means that a system does exactly what it is designed to do. Availability means the percentage of time that the system is usable.
A buggy operating system that crashes frequently, losing the user’s work, is both unreliable and unavailable. A buggy operating system that crashes frequently but never loses the user’s work and cannot be subverted by a malicious attack is reliable but unavailable. An operating system that has been subverted but continues to appear to run normally while logging the user’s keystrokes is unreliable but available.
b:
Security means the computer’s operation cannot be compromised by a malicious attacker.
Privacy is an aspect of security: data stored on the computer is only accessible to authorized users.
c:
Enforcement is how the operating system ensures that only permitted actions are allowed.
The security policy defines what is permitted — who is allowed to access what data, and who can perform what operations.
d:
Response time, sometimes called delay, is how long it takes for a single task to run, from the time it starts to the time it completes.
Throughput is the rate at which the system completes tasks. Throughput is a measure of efficiency for a group of tasks rather than a single one.
e:
Overhead means the added resource cost of implementing an abstraction presented to applications.
Efficiency is the opposite of overhead.
f:
Abstract virtual machine(AVM) means the interface provided by an operating system to its applications, including the system call interface, the memory abstraction, which instructions can be legally executed, exceptions, and signals......
Application programming interface(API) means the system call interface provided by an operating system to applications.
So API is a subset of AVM.
g:
As mentioned above, AVM includes API, memory model, legal instructions......
The operating system itself can largely be implemented independently of the hardware specifics. The interface that makes this possible is called the hardware abstraction layer (HAL). A module in the operating system that hides the specifics of different hardware implementations. Above this layer, the operating system is portable.
So AVM is for applications while HAL is for operating systems.
h:
A proprietary system is one under the control of a single company; it can be changed at any time by its provider to meet the needs of its customers.
An open system is one where the system’s source code is public, giving anyone the ability to inspect and change the code.
i:
Batch operating system is an early type of operating system that efficiently ran a queue of tasks. While one program was running, another was being loaded into memory. It runs a simple loop: load, run, and unload each job in turn.
Time-sharing(interactive) operating system is an operating-system type that designed to support interactive use of the computer.
So the difference is that Batch OS does't support interactions between users and a working machine.
j:
Some operating systems virtualize the entire computer, running the operating system as an application on top of another operating system. The operating system running in the virtual machine, called the guest operating system, thinks it is running on a real, physical machine, but this is an illusion presented by the host operating system running underneath:
So guest operating system is running in an abstraction of virtual machine provided by host operating system.
3. Define the term, direct memory access (DMA).
Hardware I/O devices transfer data directly into/out of main memory at a location specified by the operating system (bypass the CPU).
For the following questions, take a moment to speculate. We provide answers to these questions throughout the book, but, given what you know now, how would you answer them? Before there were operating systems, someone needed to develop solutions without being able to look them up! How would you have designed the first operating system?
4. Suppose a computer system and all of its applications were completely bug free. Suppose further that everyone in the world were completely honest and trustworthy.In other words, we need not consider fault isolation.
a. How should an operating system allocate time on the processor? Should it give the entire processor to each application until it no longer needs it? If there were multiple tasks ready to go at the same time, should it schedule first the task with the least amount of work to do or the one with the most? Justify your answer.
b. How should the operating system allocate physical memory to applications? What should happen if the set of applications does not fit in memory at the same time?
c. How should the operating system allocate its disk space? Should the first user to ask acquire all of the free space? What would the likely outcome be for that policy?
a:
As far as I know, the CPU contains a "TR" register which holds a segment selector for the TSS(Task state segment). Operating system can maintain a circular task linked list where all segment selector of tasks live. So when the time counter(software or hardware) set off a event, operating system change the TR register to start a new task (application).
No, since it will cause huge performance penalty. For example, while a application waiting for the packets from web server, others have "to sleep" just because this I/O event .
Except for real-time operating system, OS should check the priority of task to decide how much time CPU spend on.
b:
I think it uses the "paging" method.
Operating system will store the least active task to disk, thus making room for new task.
c:
I don't know, maybe it maintains a data structure which tells how the space on disk allocated.
Of course not.
All other users can not start any task.
5. Now suppose the computer system needs to support fault isolation. What hardware and/or operating support do you think would be needed to do the following?
a. Protect an application’s data structures in memory from being corrupted by other applications.
b. Protecting one user’s disk files from being accessed or corrupted by another user.
c. Protecting the network from a virus trying to use your computer to send spam.
a:
Use the privilege management in paging(page table) method.
b:
Create a privilege management data structure that records the files that each user have access to.
c:
Network is part of I/O, so we should ensure that only authorized application can use those I/O operations. For example, we can take advantages of the CPU rings designed by manufacturer, so when a virus running as a user program in Ring 3 should be prevented from turning on a socket without informing the user, since hardware(network card) access should be a Ring 1 function reserved for device drivers.
6. How should an operating system support communication between applications? Explain your reasoning.
a. Through the file system?
b. Through messages passed between applications?
c. Through regions of memory shared between the applications?
d. All of the above?
e. None of the above?
a:
Make all applications use the same/standard I/O operations provided by operating system, thus making sure all file in the file system follow the same data format.
b:
Maybe design a standard message send/receive mechanism for applications?
c:
Since more than one applications can modify the data on the same memory region, operating system should make sure mutex(mutual exclusion) between I/O operations from different users.
d:
¯_(ツ)_/¯ (IDK what you're talking about...