lecture no 9 central processing unit memory and its types factors affecting speed

55
Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Upload: noel-evans

Post on 22-Dec-2015

231 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Lecture No 9

Central Processing UnitMemory and Its Types

Factors Affecting Speed

Page 2: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

CPU

• Processor-on-a-chip.

• The CPU is the computer’s brain that manipulates data.

• It follows the instructions of the software to manipulate data into information.

Page 3: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed
Page 4: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

CPU’s Two Basic Parts

Each CPU has two parts:

1) Control Unit

2) Arithmetic Logic Unit

Page 5: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed
Page 6: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Control Unit

• It manages all the computer’s resources.• It tells the rest of the computer system how to carry

out a program’s instructions.• It directs the movement of electronic signals

between main memory and ALU/Input Output Devices.

• The control unit stores the CPU's microcode, which contains the instructions for all the tasks the CPU can perform.

Page 7: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Arithmetic Logic Unit

• It performs the CPU’s arithmetic and logical operations

• The actual manipulation of data takes place in the ALU.

• Arithmetic Operations:Addition, Subtraction, Multiplication and Division• Logical Operations:Comparisons, Equal to, Less than, Greater than.

Page 8: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

• The Control unit and ALU also contain set of registers to enhance the computer’s performance.

• Registers:- These are high speed staging areas that temporarily

store data during processing and provide working areas for computation.

- These hold material that is to be processed immediately.

e.g. Control Unit might load two numbers from memory into the registers in the ALU. Then it might tell ALU to divide the two numbers.

Page 9: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Machine Cycle

• A Machine cycle is a series of operations performed to execute a program instruction.

• It consists of two parts:

1) Instruction cycle

2) Execution cycle

Page 10: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Instruction Cycle

1) Fetching

2) Decoding

During the instruction cycle, the CPU fetches (Gets) a command or data from main memory and decodes it (Determines what it means)

Page 11: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Execution Cycle

1) Executing

2) Storing

During the execution cycle, the CPU executes the instruction (Performs the Operation on the data), and may store the instruction's result in memory/Register

Page 12: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Processing Speeds

• There are three ways in which processing speeds are measured:

1) Time to complete one machine cycle in fractions of a second.

2) Time to complete instructions in millions of instructions per second.

3) Time in floating point operations per second.

Page 13: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Pipelining

• Also called pipeline processing.

• The control unit begins a new machine cycle before the current cycle is completed

Page 14: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Memory

• Allows the CPU to store and retrieve data quickly.

• It consists of chips either on the motherboard or on a small circuit board attached to the motherboard.

• There are two kind of built-in memory:

1) Non-Volatile Memory

2) Volatile Memory

Page 15: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Kinds of Memory

• Read-only memory (ROM): nonvolatile

- These retain the data even when the computer/power is turned off.- The data cannot be changed except through

a special process that overwrites the data.- The Data in these is only read and used.

Page 16: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Kinds of Memory

• Random-access memory (RAM): volatile

– A Memory that temporarily holds data and instructions that will be needed by the CPU.

– Data can be stored and retrieved at random.– RAM stores data and program code needed by the

CPU. – The contents of RAM change rapidly and often.

Page 17: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Other Kinds of RAM1) Dynamic RAM (DRAM)

- DRAM Variations2) Static RAM (SRAM)

• Dynamic RAM (DRAM) chips must be recharged with electricity very frequently, or they will lose their contents.

• Static RAM (SRAM) does not need to be recharged as often as DRAM, and can hold its contents longer.

• Flash memory, can store its contents after power is turned off.

Page 18: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Factors Affecting Processing Speed

• Registers – temp memory area – 32 bit• Memory and computing power - RAM• System clock – Hz – cycles - GHz• The bus – the highway• The data bus – CPU & devices• The address bus – CPU & RAM• Cache memory – L1(CPU resident), L2 (External)

Page 19: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

How RAM Affects Speed?• More RAM means the computer can use bigger, more

powerful programs and those programs can access bigger data files.

• More RAM can also make the computer run faster.• When we run WINDOWS, the program does not

need to load all its files into memory to run properly. It loads only the most essential parts into memory.

• When the computer needs access to other parts of the program on the disk, it can unload or Swap out non essential parts from RAM to Hard disk.

Page 20: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed
Page 21: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed
Page 22: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Bus

• It refers to the path between the components of a computer.

• Two main buses:

1) Internal Bus (System Bus):

-It resides on the motherboard and connects the CPU to other devices.

2) External Bus (Expansion Bus):

- It connects external devices to the CPU.

Page 23: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Data Bus

• It is an electrical path that connects the CPU, Memory and other hardware devices on the motherboard.

• No of wires in the bus affects the speed at which data can travel between hardware components.

• 8- wire bus can move 8 bits at a time.

Page 24: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Address Bus

• It is a set of wires similar to data bus.

• It connects only the CPU and RAM and carries only memory address

Page 25: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Bus Types

• Industry standard architecture (ISA) bus 16 bit – connect devices

• Local bus – internal • Peripheral Component Interconnect (PCI) bus – fast

32 and 64 bit• Accelerated Graphics Port (AGP) bus -video • Universal Serial Bus (USB) – fast - no slots• IEEE 1394 (FireWire)- fast - no expansion slots

Page 26: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Cache memory

• Speeds processing by storing frequently used data or instructions in its high-speed memory

Page 27: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Creating Computer Programs

Page 28: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Computer Program

• A set of instructions or statements, also called code, to be carried out by the computer’s CPU.

Page 29: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Examples of Common Program Extensions

• Executable (.EXE) files• Dynamic link library (.DLL) files• Initialization (.INI) files• Help (.HLP) files• Batch (.BAT) files

Page 30: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Files

• Typically, a program is stored as a collection of files. Some common file types used in programs are:

• Executable (.EXE) files actually send commands to the processor.

• Dynamic Link Library (.DLL) files are partial .EXE files.

• Initialization (.INI) files contain configuration information for a program.

• Help (.HLP) files contain information for the user.

Page 31: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Interrupt

• A preprogrammed set of steps that the CPU follows.

Page 32: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Machine Code

• Also called machine language.

• The 1s and 0s that form the language of computer hardware.

Page 33: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Programming Language

• A Higher-level language than machine language, enables the programmer to describe a program using a variation of basic English.

Page 34: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Source Code

• File where programming language results are kept.

Page 35: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Ways to Convert Source Code to Machine Code

• Compiler – converts a source code program into machine language. Creates an executable file. – C++, Java, COBOL, Fortran, Visual Basic

• Interpreter – translates the code ‘on the fly’. Results immediately. No executable file produced. – BASIC, Unix, Perl

Page 36: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Program Control Flow

• The order in which program statements are executed

Page 37: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

How Programs Solve Problems – Program Control Flow

• The order in which program statements are executed is called program control flow.

• To determine program control flow, programmers may use a flowchart to map the program's sequence.

• Programmers may also create a simple text version of a program's code – called pseudo code – to determine how the program will flow.

Page 38: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Flowchart

• A chart that uses arrows and symbols to show the order in which a program’s statement will run.

Page 39: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed
Page 40: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Pseudo code

• Simplified text version of programming code.

Page 41: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Algorithm

• The steps represented in a flowchart that lead to a desired result are called an algorithm.

Page 42: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Common Flow Patterns

• Conditional statement:- A conditional statement determines whether a

condition is true. If so, control flows to the next part of the program.

• Loop:- A loop repeats again and again until a condition is

met. Control then passes to another part of the program.

Page 43: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed
Page 44: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Examples of Loops

• For

• While

• Do-while

Page 45: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

How Programs Solve Problems - Variables and Functions

• A variable is a named placeholder for data that is being processed. Programs contain variables to hold inputs from users.

• A function is a set of steps that are followed to perform a specific task. By assembling a collection of functions together, a developer can build a complete program.

Page 46: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Structured Programming

• The practice of building programs using a set of well-defined structures.

Page 47: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Three Control Structures of Structured Programming

• Sequence structure (flow of the program) – branch

• Selection structures (if blocks – T/F)

• Repetition or looping structures (checks a condition – loop repeats while condition is true

Page 48: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Syntax

• Programming language rules.

Page 49: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Syntax Examples

• Provide information in a certain order and structure

• Use special symbols

• Use punctuation (sometimes)

Page 50: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Three Programming Categories Based on Evolution

• Machine languages

• Assembly languages

• Higher-level languages

Page 51: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Fading Third-Generation Languages

• FORTRAN (FORmula TRANslator)

• COBOL (COmmon Business Oriented Language)

• BASIC (Beginner’s All-Purpose Symbolic Instruction Code)

• Pascal

Page 52: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Thriving Third-Generation Languages

• C

• C++

• Java

• ActiveX

Page 53: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Fourth-Generation Languages (4GLs)

• Builds programs with a front end, which is an interface that hides much of the program from the user

• Provides prototypes, which are samples of the finished programs.

Page 54: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

Examples of Fourth-Generation Languages

• Visual Basic (VB)

• VisualAge

• Authoring environments

Page 55: Lecture No 9 Central Processing Unit Memory and Its Types Factors Affecting Speed

World Wide Web Development Languages

• HyperText Markup Language (HTML)

• Extensible Markup Language (XML)

• Wireless Markup Language (WML)

• Dream weaver

• Flash

• Director