Exam 1, Question 1 Solution

Abstraction and Resource Management. (20 pts.)

In an operating system, how is the concept of abstraction tied to the notion of a privileged state? Explain in general and give one specific example.

Vertical abstraction is present in every operating system. In the simplest model, we have the hardware at the bottom, the O/S above that, and application software at the top. (We'll use this simple model for this answer but you could also divide the O/S into device drivers, O/S proper, and system software.)

Vertical abstraction is what allows us to write application software that uses high-level calls to the O/S, rather than low-level control of individual hardware components. If this abstraction is enforced (that is, if the system and application software must go through the O/S to access the hardware), then control of the hardware rests with the O/S.

Enforcement of this abstraction can only take place if the system has a privileged state. This is because, in order to run the application code, that code must be given control of the CPU. If control is turned over to application code and the application code is allowed to run with the same privileges as the O/S, it could send commands directly to the hardware, as the O/S does.

Conversely, it makes no sense to have a privileged state in an O/S without abstraction. With no vertical abstraction, an application program would have to control the hardware directly in order to achieve its functions. But, if it has direct hardware access, then it can determine exactly what the hardware does with no way for the O/S to prevent it.

For example, consider a disk drive. With typical vertical abstraction, the application program deals with files and directories. When it wants to save data, it tries to write to a file, and the O/S translates that request into a determination of what bytes are sent to what region of the disk drive. Following the abstraction, the application program cannot overwrite any part of the disk drive without the permission of the O/S. However, if there were no notion of a privileged state, then the application would not have to send write requests to the O/S. It could, instead, simply use the same types of instructions used by the O/S and send bytes directly to any region of the disk.

Or, to take the converse in the example, if there were no file, directory, or other I/O abstractions provided by the O/S, then in order for the application program to save any data it would have to send instructions directly to the disk drive to save certain bytes in certain locations. But with this direct disk access, it could overwrite any data saved anywhere on the disk by any process, so there would be no privileged state with regard to the disk drive.

(Your answer need not be this long.)