cse 5311 fundamentals of computer science

42
CSE 5311 Fundamental s of Computer Science Computer System Overview

Upload: lamont

Post on 20-Mar-2016

55 views

Category:

Documents


4 download

DESCRIPTION

CSE 5311 Fundamentals of Computer Science. Computer System Overview. Computer Systems. Computer systems have two major aspects - hardware and software. Hardware - The parts of the computer you can actually see and touch. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSE 5311 Fundamentals of Computer Science

CSE 5311Fundamentals of

Computer Science

Computer System Overview

Page 2: CSE 5311 Fundamentals of Computer Science

Computer Systems Computer systems have two major aspects - hardware

and software. Hardware - The parts of the computer you can actually

see and touch. The hardware (in a programmable computer) is

directed by the software to carry out tasks. Software - Instructions and data stored in memory (a

type of hardware) in the form of magnetic or electrical impressions.

The instructions are used to control the hardware.

Page 3: CSE 5311 Fundamentals of Computer Science

Hardware

Hardware can be divided into three groups: Processing

• Central Processing Unit (CPU)– Arithmetic Logic Unit (ALU)– Control Unit (CU)– Floating-Point Unit (FU)– Memory Manager (MM)

• Direct Memory Access (DMA) controller• Various other device controllers.

Input/Output Devices• Keyboard• Mouse• CRT• Printer• Disk Drive

Page 4: CSE 5311 Fundamentals of Computer Science

Hardware

Hardware can be divided into three groups (continued):

Memory• Random Access Memory (RAM)• Read Only Memory (ROM)• Disks

– Floppy– Hard– CD– DVD

• Tape• Registers• Cache (associative memory)

Page 5: CSE 5311 Fundamentals of Computer Science

Computer-System Architecture

Page 6: CSE 5311 Fundamentals of Computer Science

Memory

Page 7: CSE 5311 Fundamentals of Computer Science

Memory Memory can be viewed in a hierarchical structure:

REGISTERS

CACHE

RAM

DISKS

volatile

non-volatile

Page 8: CSE 5311 Fundamentals of Computer Science

Memory

A program must exist in memory in order to execute.

When a program is executed, it begins a process of migration from disk memory to RAM, cache, and register memory.

Depending on a programs size, as it executes parts of it may move back and forth between disk memory and register memory many times. The operating system is chiefly responsible

for data migration.

Page 9: CSE 5311 Fundamentals of Computer Science

32-Bit Intel Register Set

There is also a set of floating point registers

Page 10: CSE 5311 Fundamentals of Computer Science

Disk Surface Physical Organization Every disk is organized into tracks, which in turn are divided into sectorsWithin a sector the bit is the smallest data unitSectors are logically grouped by the OS into clusters

Page 11: CSE 5311 Fundamentals of Computer Science

Logical Disk Organization

Every formatted disk contains one boot record, a root directory, and two file allocation tables. The remainder of the disk space is “data area”

Page 12: CSE 5311 Fundamentals of Computer Science

Physical Organization of Hard Drive

Each disk surface has a head which is fixed to the end of an access arm. All arms and heads are moved simultaneously by a single actuator.

Page 13: CSE 5311 Fundamentals of Computer Science

Disk Drive Actuators

The actuators is responsible for the movement of the read/write heads.

Page 14: CSE 5311 Fundamentals of Computer Science

Physical Organization of Disks

On hard drives the read/write “floats” above the disk surface. Disk constantly rotates.On floppy drives the read/write head touches the disk surface. Disk only rotates when a read or write is in process.

Page 15: CSE 5311 Fundamentals of Computer Science

Software

Software can be divided into two groups: Systems programs

• Operating system• Program translators

– assemblers– compilers– interpreters

• Linkers• Loaders• Device drivers (may be considered as part of the OS)• Note: Some persons consider operating systems to be the

only true system program. Everything else is considered an application program.

Page 16: CSE 5311 Fundamentals of Computer Science

Software

Software can be divided into two groups: Application programs

• payroll programs• games• spreadsheets• tax preparation software• text editors

Page 17: CSE 5311 Fundamentals of Computer Science

Operating Systems The job of the operating system is to manage system

resources by maximizing the throughput of the computer system.

This is accomplished by keeping all hardware resources as fully occupied as possible.

The operating system provides a buffer between human users and the hardware and other programs and the hardware.

OS HWPrograms

User

Page 18: CSE 5311 Fundamentals of Computer Science

OS in Relation to Other System Components

Page 19: CSE 5311 Fundamentals of Computer Science

Program TranslatorsCompilers

AssemblersInterpreters

Page 20: CSE 5311 Fundamentals of Computer Science

The Translation Process

Lexical Analysis

Parsing Code Generation

source program object program

All translators follow this general process. However, for high-level languages the process is much more complex than for low-level languages.

Page 21: CSE 5311 Fundamentals of Computer Science

Compilers Compilers convert programs written in a high-level language into

machine language. Machine language is used to communicate with the CPU. Examples of high-level languages that depend on compilers: C,

C++, PL/I, COBOL, FORTRAN, Pascal. High-level languages have a one-to-many translation ratio.

One high-level instruction is translated by the compiler into one or more machine instructions.

Compilera = b + c;

Mov b to register ax

Add c to register ax

Mov register ax to a

Page 22: CSE 5311 Fundamentals of Computer Science

The Compilation and Linking Process

High-level Source Code

Compiler Object File

Linker

Executable File

Object Library

Object Library

Page 23: CSE 5311 Fundamentals of Computer Science

Compilers All programming languages must be formally defined. A language’s formal definition is known as its grammar. The grammar is used to indicate is a sequence of source

code symbols (tokens) are syntactically correct. There are different notations available for writing

grammars The parser is the part of the compiler that, based on the

grammar, determines if the program is syntactically correct.

Page 24: CSE 5311 Fundamentals of Computer Science

Compilers

Grammar for a simplified version of Pascal expressed using Backus-Naur Form (BNF) notation.

• Upper-case tokens represent reserve words.• ‘id’ represents identifiers• ‘int’ represents an integer constant

Page 25: CSE 5311 Fundamentals of Computer Science

Compilers

Pascal program that conforms to the proceeding grammar.

Page 26: CSE 5311 Fundamentals of Computer Science

Compilers Lexical analysis is the

process of breaking the source code into tokens

Tokens may optionally be assigned a numeric code

The scanner is the part of the compiler that performs lexical analysis

Tokens requested by the parser one at a time

Page 27: CSE 5311 Fundamentals of Computer Science

Compilers

Recursive-descent parse of an assignment statement TOKEN represents the most recent token returned by the scanner ‘advance to next token’ represents a call to the scanner to provide the

next token in the source file input stream

assign ::= id := <exp>

Page 28: CSE 5311 Fundamentals of Computer Science

Compilers

Recursive-descent parse of an expression statement

exp ::= <term> { + <term> | - <term> }

Page 29: CSE 5311 Fundamentals of Computer Science

Assemblers Assemblers convert programs written in a low-level

language into machine language. Examples of low-level languages that depend on

assemblers: Intel 8086-based assembler, Motorola 6800-based assembler, IBM System 360/70 assembler.

Low-level languages have a one-to-one translation ratio. One assembly instruction is translated by the assembler

into one machine instruction.

Assembler

Mov b to register ax

Add c to register ax

Mov register ax to a

mov ax,b

add ax,c

mov a,ax

Page 30: CSE 5311 Fundamentals of Computer Science

Machine Code

Object files and executable files are mostly composed of machine instructions. Compilers and Assemblers produce machine code; Interpreters produce p-code (byte code).

The first byte of a machine instruction is known as the opcode. The opcode indicates what type of operation (add, subtract, etc.) the instruction is to carry out.

The length of the machine instruction varies according to the number of operands and addressing modes used.

opcode mod reg r/m immed-low

Mod R/Mimmed-high disp-low disp-high

7 -- 07 7 6 5 3 2 0140(The opcode indicates whether or not the immediate value field is present, as well as its size.)

7 -- 07 -- 07 -- 0

Intel Instruction Format (8086/8088)

Page 31: CSE 5311 Fundamentals of Computer Science

The Assembly and Linking Process

Low-level Source Code

Assembler Object File

Linker

Executable File

Object Library

Object Library

Page 32: CSE 5311 Fundamentals of Computer Science

Interpreters Interpreters “execute” programs written in a high-level

language without converting it into machine language. Examples of languages that depend on interpreters:

Quick BASIC, Java, Lisp, Smalltalk, Visual Basic. Interpreters do not product object files containing

machine code, but sometimes produce pseudo code.

Interpreters allow for features such as automatic garbage collection

Interpretera = b + c;

Assign (temp, Add (b,c))

Assign (a, temp)

Page 33: CSE 5311 Fundamentals of Computer Science

Interpreters The interpreter provides a virtual run-time environment A Java interpreter is called a “virtual machine”

p-codeinterpreter

operating systemhardware

software

Page 34: CSE 5311 Fundamentals of Computer Science

The Interpretation Process

High-level Source Code

Interpreter(translation

mode)

P-code File

Interpreter(execution

mode)

P-code Library

P-code Library

Page 35: CSE 5311 Fundamentals of Computer Science

Basic Hardware Architecture

Page 36: CSE 5311 Fundamentals of Computer Science

Computer-System Architecture

Page 37: CSE 5311 Fundamentals of Computer Science

Basic Architectural Components

The central processor communicates with main memory and I/O devices via buses

Data bus for transferring dataAddress bus for the address of a memory location or an I/O portControl bus for control signals (Interrupt request, memory read/write …)

Each operation must be synchronized by the system clockRegisters are high-speed storage within the processor

Page 38: CSE 5311 Fundamentals of Computer Science

Simplified CPU Design

Page 39: CSE 5311 Fundamentals of Computer Science

Central Processing Unit Typically a general purpose CPU will contain:

Arithmetic Logic Unit Floating Point Unit

• Similar to ALU but works with floats Register File

• Contains all registers (not a true file) Memory Management Unit

• Performs logical to physical address translation Control Unit

• Tells the ALU and FPU which operations to carry out.

Page 40: CSE 5311 Fundamentals of Computer Science

The Fetch-Decode-Execute CycleIs the basic cycle for instruction execution

Fetch the next instruction • place it in queue• update program counter register

Decode the instruction • perform address translation• fetch operands from memory

Execute the instruction• store result in memory or registers• set status flags according to result

Before fetching next instruction, the CPU checks if an interrupt is pending (more on that later)

Page 41: CSE 5311 Fundamentals of Computer Science

MicrocodeThe circuits in most general-purpose processors (Intel, Motorola, IBM) are directly controlled by software known as microcode (aka firmware).Microcode resides in a type of read-only memory known as control memory.When a machine instruction is fetched from RAM by the processor to be executed, the machine instruction’s op code serves as an address of a micro- coded subroutine in control memory that “executes” the machine instruction.

Page 42: CSE 5311 Fundamentals of Computer Science

Simplification of a Micro Code-

Driven Architecture

The Function Unit is the same as the ALUMemory M is RAM and ROM