eit - infosys material

54
Computer Hardware and System Software Concepts Introduction to Computer Architecture

Upload: ankeet-panda

Post on 03-Mar-2015

151 views

Category:

Documents


12 download

TRANSCRIPT

Page 1: EIT - Infosys Material

Computer Hardware and System Software ConceptsIntroduction to Computer Architecture

Page 2: EIT - Infosys Material

2Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Course Objective

To introduce fundamentals of Computer Architecture

To introduce the concepts of System Software.

To introduce the concepts of Operating Systems.

To introduce the concepts of Computer Networks.

Page 3: EIT - Infosys Material

3Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

References

Andrew S. Tanenbaum: Structured Computer

Organization , PHI, 3rd edition, 1991.

Silberschatz and Galvin: Operating System Concepts , 4th

edition, Addison-Wesley Pub, 1995.

Andrew S. Tanenbaum: Computer Networks, PHI, 1991.

Alfred V.Aho, Ravi Sethi, Jeffrey D.Ullman: Compilers -

Principles, Techniques and Tools, Narosa Publishing

House, 1986.

Page 4: EIT - Infosys Material

4Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Session Plan

Day 1

– Create a background

– Main components of computer architecture

– Different addressing modes

Day 2

– Introduce System Software

– Introduce Operating Systems/Memory Management

Page 5: EIT - Infosys Material

5Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Session Plan

Day 3

– Introduce Process Management

– Introduce File Management

Day 4

– Introduce Device Management

– Introduce Computer Networks

Page 6: EIT - Infosys Material

6Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Background

What is a Computer?

– Is an electronic device used to

• Store

• Retrieve and,

• Process data.

– To process data a set of instructions need to be given to the

computer.

What is a Program?

– Is a set of instructions.

Page 7: EIT - Infosys Material

7Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Computer Architecture

Is concerned with the structure and behavior of the

computer as seen by the user/programmer. It includes

attributes such as

– Instruction Formats

– Addressing Modes

– Instruction Sets

– I/O Mechanisms

Page 8: EIT - Infosys Material

8Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Computer Architecture

Main components in a computer system

Hardware

Software

Firmware

Page 9: EIT - Infosys Material

9Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Organization of a simple computer

•Central Processing Unit (CPU)

•Main Memory

•Input / Output devices

•Bus

Page 10: EIT - Infosys Material

10Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

CPU (Processor)What is it?

Brain of the computer

Function

– Fetch instructions from memory

– Examine

– Execute

Consists of 3 functional units

– Control Unit (CU)

– ALU

– Registers

Page 11: EIT - Infosys Material

11Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

CPU – Functional Units

Control Unit

ALU

Registers

Fetches Instructions from memory

Interprets the instructionsCPU

Performs arithmetic operations

Performs Logical operations

Very high speed memory units in the CPU-for storing very small amount of data.

Examples

•Program Counter (PC)

•Instruction Register (IR)

•Memory Address Register (MAR)

•Memory Buffer Register (MBR)

•Accumulator (A)

Page 12: EIT - Infosys Material

12Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Examples of CPU (Processor)

Intel Processors

8088

80286

80386

80486

Pentium

Motorola Processors

68000

68020

68030

Page 13: EIT - Infosys Material

13Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

MemoryMEMORY

Internal

Memory

Main

Memory

Cache

Memory

Secondary

Memory

RAM ROMInternal

Cache

External

Cache

Page 14: EIT - Infosys Material

14Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Memory – Internal Memory

In the form of Registers

Registers are small memory units internally

available within the CPU.

Volatile/Non volatile Memory

Page 15: EIT - Infosys Material

15Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Memory - Primary or main Memory

Volatile/Non volatile Memory

Main Memory

Random Access

MemoryRead Only

Memory

Page 16: EIT - Infosys Material

16Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Memory - Cache Memory

A memory placed between CPU and main memory

Contains a copy of the portion of main memory

Processor when needs some information first checks cache

If not found in cache, the block of memory containing the needed

information is moved to the cache

CPU

Cache

Main Memory

Page 17: EIT - Infosys Material

17Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Memory - Secondary memory devicesType Description Readable Writable

Typical

size Hard disk

These are placed separately along with the CPU (in the

cabinet) and are usually not portable.

Yes Yes 40 GB 80 GB

Floppy disk

The Floppy disks are portable. These come in smaller sizes compared to Hard

Disk.

Yes Yes 1.44 MB

CD ROM Compact Disc, Read Only Memory

(CD-ROMs) are portable. These are typically read-only, meaning they could be used only to read the contents.

Yes No 650-700MB

CD Read/ Write

This is simillar to CD-ROMs except that it is also used to write the information on to the special CD-ROM which are of Read-Write type.

Yes Yes 650-700 MB

Page 18: EIT - Infosys Material

18Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Comparison of different types of memoryStorage type Implementation

FeaturesContents Example Typical Size

Internal Memory

Very high speed devices, located within CPU(chip); expensive, and volatile. Very costly, hence limited in capacity.

Holds instructions under execution and associated data item.

Registers, Internal Cache memory

Registers will be few in number.The internal Cache could be 256 KB or 512 KB

Primary Memory

High speed devices (but slower than the internal CPU registers) located outside the CPU (on the motherboard), Less costlier compared to internal memory. Usually larger in capacity.

Entire (almost) program contents being executed; holds small volume of data.

RAM (volatile), ROM (Non volatile), External Cache Memory

256 MB512 MB

Secondary Memory

Low speed, Non-volatile, low cost.Huge in capacity.

Programs not currently being executed; holds large volume of data

Hard Disk, Compact Disks(CDs), Floppy disks

40GB80 GB

Page 19: EIT - Infosys Material

19Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Memory hierarchy

Page 20: EIT - Infosys Material

20Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Bus

Parallel wires that carry several bits at a time

Carries instructions, data, addresses or commands

Unidirectional or bi-directional

Major Categories

– Data bus

– Address bus

– Control bus

Bus width and Bus speed are the two major components for performance

measure.

Page 21: EIT - Infosys Material

21Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Different types of registersCategories:-

General Purpose Registers

– are those which are used by the programmer to store data.

– all CPUs will have one register called Accumulator.

Special Purpose Registers

– The special purpose registers are used by the CPU for temporary storage of data for

calculations and other purposes.

– Ex.:

• MAR

• MBR

• IR

• PC

Page 22: EIT - Infosys Material

22Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Registers, CPU and the memory

Page 23: EIT - Infosys Material

23Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Harvard Architecture - Data & program stored separately.

The Advantages of this architecture is the clear separation of the data region and the code region. Also the separate data and program busses are used, hence speeding up the process.

Disadvantages could be the separate mechanisms to fetch data and the programs.

Page 24: EIT - Infosys Material

24Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Von Neumann architectureData & Program, both stored in the same place.

The Advantages of this architecture is that it treats data and programs alike meaning the same mechanisms to fetch data and the programs.

The disadvantage is the same bus used for both program as well the data leads to so called Von Neumann bottleneck.

Page 25: EIT - Infosys Material

25Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Von Neumann architecture - characteristics

One processor

Use of stored programs

Sequential processing of instructions

Single Instruction, Single Data stream (SISD) mode

Page 26: EIT - Infosys Material

26Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Execution of the Instructions

The execution process of the instruction stored in the memory happens in

three phases.

Fetch Phase: In this phase the instructions retrieved picked from the memory.

Decode Phase: Once the instructions are retrieved these are decoded by the

CU.

Execute Phase: Once the instructions are decoded, they are executed by the

ALU (in case they are Arithmetic instructions).

Page 27: EIT - Infosys Material

27Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Fetch-decode-execute cycle

Special Registers

CPU

Control Unit .....

.

.

.

Memory

ALU

GPRR3 R4

MAR

ProgramCounter

InstructionRegister

MBR

InstructionDecoder

R2R1

5000 1A

ADD R1,R2

Page 28: EIT - Infosys Material

28Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Fetch-decode-execute cycle

Fetch Phase

Decode Phase

Execute Phase

Page 29: EIT - Infosys Material

29Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Fetch phase

Contents of PC are transferred to MAR

Main memory is accessed and current instruction is fetched into MBR

Instruction is transferred from MBR to IR

Page 30: EIT - Infosys Material

30Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Decode phase

Opcode of the instruction is decoded

Contents of PC are incremented by 1(in case of 1 byte instruction or equal to

the no. of bytes of the instruction currently being executed.)

Execution phase follows ( specific to the given instruction )

Page 31: EIT - Infosys Material

31Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Execute phase

Execute the instruction

Store the results in the proper place (go to the fetch phase to begin executing

the next instruction)

Page 32: EIT - Infosys Material

32Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Fetch-decode-execute cycle-Example 2

Page 33: EIT - Infosys Material

33Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Instruction categories

Arithmetic Instructions

– Ex.: Add, Sub, Mul etc.

Logical instructions

– Instructions doing comparison operations.

Program Control instructions

– Ex.: Jump to some memory location where the code is place & return etc.

I/O instructions

– Ex.: In, Out

Data Transfer instructions

– Register-Memory / Memory-Register

– Register-Register

– Memory-Memory.

Page 34: EIT - Infosys Material

34Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Instruction categories (Cont…)

From Registers toMemory

From Memmory toRegisters

Arithmetic Logic Unit (ALU)

Control Unit

Central Processing Unit (CPU)Mem

ory

Memor

y to

mem

ory

REGISTERS

R1 R2

R3 R4

MAR

IR PC

MBR

Data Transfer instructions

Register-Memory / Memory-Register

Register-Register

Memory-Memory.

Page 35: EIT - Infosys Material

35Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Variations of CPU Architecture

SISD

SIMD

MIMD

MISD

Page 36: EIT - Infosys Material

36Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

I/O devices

Why needed?

O/P Devices:

PrinterMonitor

Page 37: EIT - Infosys Material

37Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

I/O devices

Input Devices:-

KeyboardMouse

Page 38: EIT - Infosys Material

38Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

I/O devices

Input/Output Devices

Page 39: EIT - Infosys Material

39Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Measures of CPU performance

MIPS - is a measure of the speed of the processor.

Clock Speed – is another metric used to measure

performance.

FLOPS – is a measure of the speed of the Floating Point

Unit (FPU) which is a co-processor unit.

Page 40: EIT - Infosys Material

40Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Addressing

A way of accessing memory locations which contain the data for

processing

Modes of addressing

– Implied Addressing

– Immediate Addressing

– Direct or Absolute Addressing

– Relative Addressing

– Indirect addressing

Page 41: EIT - Infosys Material

41Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Implied Addressing

Operands are specified implicitly in the definition of the instruction

Instruction specifies a fixed and unvarying address

Example:- DEC (Decrement A register)

1. The CU decodes the instruction (fetch and decode phase)

2. The CU then fetches the contents of the register A

3. The value of the A will be transferred to the ALU

4. The ALU then decrements this value and updates the register A

Page 42: EIT - Infosys Material

42Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Immediate addressingIn it, data is a part of instruction itself.

Example:- MOVE #100H, R1

• Here the data 100h is moved to R1.

The following steps are involved in the execution of this instruction.

– The CU decodes the instruction (fetch and decode phase)

– The data 100H available with the instruction is sent to Register R1.

Control UnitR1

MOVE #100H R1

2

1

Page 43: EIT - Infosys Material

43Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Direct (Absolute ) addressing

The address where data is available is part of the instruction

Ex.: MOVE 30A4, R1

75

MOVE 30A4H R1

Control Unit R1

1

30A4

2

3

Page 44: EIT - Infosys Material

44Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Problem with Direct Addressing

Page 45: EIT - Infosys Material

45Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Indirect Addressing

Problem of direct addressing :the change in the location of the

program is associated with the change in all absolute memory

references.

Solution : is to represent the address of the data indirectly.

There are two ways to do it:

– 1) Register Indirect Addressing : the address of the data is

stored in a Register.

– 2) Memory Indirect Addressing : the address of the data is stored

in another memory location

Page 46: EIT - Infosys Material

46Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

1) Register Indirect Addressing :Ex.: MOVE [R2], R1

Memory

MOVE [R2] R1 R1

Control Unit

17530A4

4

R2

3

2

The register R2 is assumed to be pre- loaded with a value of 30A4

Page 47: EIT - Infosys Material

47Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

1) Memory Indirect Addressing :Ex: MOVE [ 7010 ], R1

Page 48: EIT - Infosys Material

48Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Problems with Indirect Addressing

Page 49: EIT - Infosys Material

49Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Base - Indexed AddressingEx.: MOVE [BX] + [Ri], R1.

hold the Base value of the

program. holds the

Offset (relative) address.

Memory

3000

IndexRegister Ri

BaseRegister

(BX)

R1

20A4

MOVE [BX] [Ri] R1

75

+3 3

50A4

4

75

ADDER(ALU)

3000 20A4

21

5

Page 50: EIT - Infosys Material

50Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Problem with usage of shared memory

Page 51: EIT - Infosys Material

51Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Segment Register Addressing

Page 52: EIT - Infosys Material

52Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Segment Register Addressing

MOVE [SR]

Memory

50000

IndexRegister Ri

BaseRegister

(BX)

R1

100

[BX] [Ri] R1

75

+3 3

51100

4

75

ADDER(ALU)

1000 100

21

Segment1(code)

Segment2(Data)

51000

100050000

0

3

SegmentRegister

(SR)

Segment3

5

Page 53: EIT - Infosys Material

53Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Summary

Background

Components of a computer system

Von Neumann architecture

Fetch Decode Execute Cycle

Memory

I/O devices

Bus

Addressing Modes

Page 54: EIT - Infosys Material

54Copyright © 2004, Infosys Technologies Ltd

ER/CORP/CRS/OS09/003

Version No: 2.0

Thank You!