Sunteți pe pagina 1din 6

Operating Systems Implementation A Modern Computer System 2

COMP3300 Simplistically a modern computer system looks like a bus with


the following hanging off it: CPU(s), memory, and devices
accessed through controllers.
Computer System Structures

Department of Computer Science Display Keyboard


Disk
The Australian National University CPU Memory Controller Controller Controller

Eric McCreath System Bus


This conceptual model provides a good frame work when
2004 considering operating system issues.

Bootstrapping 3 Main Memory 4

When a computer is switched on or reset there must be an Main memory is the only large storage area that the CPU can
initial program that gets the system running. This program is directly access. Hence, any programs that are currently being
called the bootstrap and tends to be simple. The bootstrap executed must be in main memory. This includes critical parts
program will: of the operating system. Main memory is one of the key
initialize a variety of registers, devices, memory control resources for the operating system to manage.
devices, Main memory consists of an array of words or bytes.
load the operating system into memory, and
start the operating system running. 0
1
10101111
11001100
2 10010011
3 10010000
4 10010111
5 11111000
6 11111111
7 11111111
: :
The Cache 5 The Cache 6

There are a number of design issues that effect the


The cache sits between the CPU and the main memory and it performance of the cache. These include:
improves the performance of the computer as CPU's can
request words from memory faster than main memory can cache size
provide them. The cache is effectively invisible to both the block size
CPU and main memory.
mapping function and replacement algorithm
write policy
Consider the following example:
4-bit addresses Main Memory
CPU cache Main Memory 16-bit data(word size) Tag Blocks 0111
2-bit tags 1000 he
4 word block length 1001 ll
3 line cache 1010 o
1011 wo

10 he ll o wo 1100 rl
d!

Inside the CPU 7 A Simple CPU Design 8

Data Lines
There are a number of key components that are contained
inside the CPU(Central Processing Unit). These include:
Control Unit : This directs the flow of information within the CPU. Instruction Register
Register 1
ALU(Algorithmic and Logic Unit) : This unit does the basic
computation within the CPU. Register 2 Clock
Control
Registers : These are to store words that are currently being processed Unit

Address Lines
within the CPU. Register 3
Instruction Pointer : A register that points to the next instruction in Inc
memory to execute. ALU
Instruction Register : The register that contains the current instruction MUX
that is being executed.
Instruction Pointer
Instruction Cycle 9 Instructions 10

There are a number of different types of instruction. These


include:
2. Interpret Moving binary information about. (e.g. Move the value
1. Fetch
instruction instruction from a register to a memory location.)
Processing binary information. (e.g. Add two registers
and place the result in a third register.)
Flow control. (e.g. Jump to the instruction at a particular
memory location and start executing from there.)

3. Execute
4. Increment instruction
instruction pointer

Instructions 11 Example 12

The assembly language instruction can be divided into two Consider the following line of code:
parts: x := y + 7;
Operation code(op code) - tells the CPU which operation to Suppose the variable x is stored in memory location A0. y is
perform. stored in location A1.
Operands - these are the parameters for the operations. They The assembly instructions of this line of code would look
could be : address locations, register indexes, or values. something like :

This add the values 0 21


ADD A <- 3 5 Load 1 <- #07 1 07
Hexadecimal in registers 3 and 5 Load 2 <- A1 2 12
5 A 3 5 and then places the 3 A1
Add 3 <- 1 2 4 53
Binary 0101 1010 0011 0101 result in register A. Store 3 -> A0 5 12
6 33
7 A0

Op-code Operands
Interrupts 13 Interrupts 14

Interrupts are a critical part of a modern computer's


When an interrupt occurs the interrupt vector is used to
architecture. This is for the following reasons:
determine the routine to execute to handle the interrupt.
they allow a program to be 'interrupted' so the computer may
deal with an urgent event,
Interrupt Vector
they provide a secure mechanism for user programs to call
the operating system, and
interrupts provide a way of catching the execution of illegal
operations or access to memory that is outside its address space
(or is not in physical memory).
OS code for handling
User process executing divide by zero trap.

OS device driver executing


OS code for handling
IO for device complete timer interrupt

Interrupts 15 DMA 16

Interrupts must be handled quickly. Direct Memory Access(DMA) enables the computer to move
The interrupt handler must return the state of the process to blocks of memory to and from devices or within memory. This
is achieved by stealing bus clock cycles from the CPU.
exactly the way it found it. This will clearly involve saving
and resorting the program counter and any other registers that For low speed devices, such as a serial port, interrupts are
are used by the interrupt handler. The complete state of the sufficiently efficient to handle this data transfer.
running process is not saved, as this would be a waste of time. However, for high speed devices, such as a network card,
Usually, other interrupts are disabled while an interrupt is interrupts are insufficient. As the rate of requests is faster than
being handled. Some architectures support priorities for the rate the handler can deal with them.
interrupts. So an interrupt handler may be interrupted by an The operating system sets up control information, counters,
interrupt with higher priority.
and pointers for the transfer. Once the DMA transfer is
Modern operating systems are interrupt driven. Events are complete the operating system can be informed by an
signaled by an interrupt or a trap(software interrupt). interrupt.
Storage Structure 17 Storage Structure 18

In the von Neumann style architecture instructions are fetched Magnetic disks are the most common from of secondary
from main memory and executed. Instructions will Load/Store storage as they are able to hold large quantities of data and are
from/to main memory. However, from the memories non-volatile.
perspective all that is seen is a series of addresses with either a Most programs will remain on disk until required. Also the
read or write command.
disk is the main location that non-temporary data is stored.
It would be nice to store all data and programs in main Hence, efficient management of the magnetic disk is critical
memory. However, this is not possible for two reasons: for a system to run well.
the size of memory is generally too small,
contents is lost when power is turned off(it is usually a
volatile storage device).

Storage Structure 19 Storage Hierarchy 20

Some architectures have special instructions for the CPU to There is a variety of storage devices computers may store
communicate with I/O devices. information within. They may be arrange in a hierarchy in
terms of : cost per bit, capacity, and speed.
Other use memory-mapped I/O where control, data, and status
registers of a device sit in fixed locations in the memory space.
Registers
(it is not real memory it just looks like it from the CPU) The
CPU may view these locations as ordinary memory and Cache
simply load and store data to and from these locations to
Main Memory
achieve the required I/O.
Electronic Disk

Magnetic Disk

Optical Disk

Magnetic Tapes
Hardware Protection 21 Hardware Protection 22

Hardware protection is provided by most architectures to Dual-Mode Operation : there is two modes of operation user
prevent user programs running wild. mode and monitor mode( also called supervisor, system, or
A user program may contain bugs or be malice. In either case privileged mode). Restrictions are placed on what instruction
it is undesirable that this user program can adversely effect may be executed in user mode. A trap occurs if a user program
attempts to execute a privileged instruction.
either the operating system or other user programs. As user
programs generally execute directly on the CPU, hardware I/O Protection : user programs are general prevented from
protection is essential to make the computer system more directly performing any I/O operations. Hence, all I/O must be
reliable/stable. done through the operating system.
CPU Protection : a user program should be prevented from
taking control of the CPU. This may be achieved by using a
timer that causes an interrupt.

Hardware Protection 23

Memory Protection – a user program must be prevented from


reading or writing to other programs or the operating systems
memory. An example of this would be to use base and limit
registers to trap errant memory requests.
Base

Monitor
+

CPU Limit 0
Job 1

<
>=
Job 2
Address Error

S-ar putea să vă placă și