|
Introduction ContinuedFriday, September 3 Instruction Fetch and Execute CycleThe instruction fetch and execute cycle of the computer was discussed.
AcknowledgementIn the following much of the information presented, including the figures, is from the book The Design of the UNIX Operating System by Maurice Bach. Hardware Support Needed for UnixIn order to be able to port Unix to a new architecture, certain features must be present in the hardware of that architecture.
A software interrupt acts the same as a hardware interrupt or exception. It occurs when special instructions, called trap, or supervisor call, instructions are executed. These instructions are provided so that user programs can call OS routines to perform hardware tasks that users (running in user mode) are not allowed to do (i.e., they are performed with privileged instructions). Consider the following example: A high level user program may include a line like
The compiler may translate this into something like
In actuality, this is a more complex operation, because reading from the keyboard means reading ascii characters that must be converted into a numeric value if A is, say, an integer variable. Still, the concept is that in order to perform the read, the user program must issue a system call, because the actual instructions to do the read are either privileged, or the address for accessing the keyboard is out of bounds to the user. All hardware tasks are thus performed by way of system calls to the operating system. In this case, the execution by the processor of the Syscall instruction would do something like the following in one single machine instruction cycle:
Once this is done, the next instruction fetch retrieves the first instruction of the syscall routine in the OS and the syscall begins executing in supervisor mode. Conceptual Design of UnixThe general philosophy that Unix follows in its design is a "concentric layered design." In this logical view of Unix, the Unix kernel (which is just another name for the operating system) "surrounds" the hardware. Users can only access the hardware (e.g., read from a disk) by calling kernel functions (by way of trap, or supervisor call, instructions) that perform the hardware access for the user. The layered approach just means that as other application programs are designed, they in turn may call user routines that have already been written to get the desired task done, and these routines my further call other routines or kernel routines. This layering can go on as far as desired.
Functional Design of UnixFunctionally, Unix looks more like the following. We just got started with this and will look at it some more.
|
|