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

Post on 22-Dec-2015

231 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Lecture No 9

Central Processing UnitMemory 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.

CPU’s Two Basic Parts

Each CPU has two parts:

1) Control Unit

2) Arithmetic Logic Unit

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.

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.

• 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.

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

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)

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

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.

Pipelining

• Also called pipeline processing.

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

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

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.

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.

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.

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)

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.

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.

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.

Address Bus

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

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

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

Cache memory

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

Creating Computer Programs

Computer Program

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

Examples of Common Program Extensions

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

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.

Interrupt

• A preprogrammed set of steps that the CPU follows.

Machine Code

• Also called machine language.

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

Programming Language

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

Source Code

• File where programming language results are kept.

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

Program Control Flow

• The order in which program statements are executed

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.

Flowchart

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

Pseudo code

• Simplified text version of programming code.

Algorithm

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

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.

Examples of Loops

• For

• While

• Do-while

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.

Structured Programming

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

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

Syntax

• Programming language rules.

Syntax Examples

• Provide information in a certain order and structure

• Use special symbols

• Use punctuation (sometimes)

Three Programming Categories Based on Evolution

• Machine languages

• Assembly languages

• Higher-level languages

Fading Third-Generation Languages

• FORTRAN (FORmula TRANslator)

• COBOL (COmmon Business Oriented Language)

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

• Pascal

Thriving Third-Generation Languages

• C

• C++

• Java

• ActiveX

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.

Examples of Fourth-Generation Languages

• Visual Basic (VB)

• VisualAge

• Authoring environments

World Wide Web Development Languages

• HyperText Markup Language (HTML)

• Extensible Markup Language (XML)

• Wireless Markup Language (WML)

• Dream weaver

• Flash

• Director

top related