cse 5311 fundamentals of computer science
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 PresentationTRANSCRIPT
CSE 5311Fundamentals 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. 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.
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
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)
Computer-System Architecture
Memory
Memory Memory can be viewed in a hierarchical structure:
REGISTERS
CACHE
RAM
DISKS
volatile
non-volatile
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.
32-Bit Intel Register Set
There is also a set of floating point registers
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
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”
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.
Disk Drive Actuators
The actuators is responsible for the movement of the read/write heads.
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.
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.
Software
Software can be divided into two groups: Application programs
• payroll programs• games• spreadsheets• tax preparation software• text editors
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
OS in Relation to Other System Components
Program TranslatorsCompilers
AssemblersInterpreters
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.
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
The Compilation and Linking Process
High-level Source Code
Compiler Object File
Linker
Executable File
Object Library
Object Library
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.
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
Compilers
Pascal program that conforms to the proceeding grammar.
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
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>
Compilers
Recursive-descent parse of an expression statement
exp ::= <term> { + <term> | - <term> }
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
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)
The Assembly and Linking Process
Low-level Source Code
Assembler Object File
Linker
Executable File
Object Library
Object Library
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)
Interpreters The interpreter provides a virtual run-time environment A Java interpreter is called a “virtual machine”
p-codeinterpreter
operating systemhardware
software
The Interpretation Process
High-level Source Code
Interpreter(translation
mode)
P-code File
Interpreter(execution
mode)
P-code Library
P-code Library
Basic Hardware Architecture
Computer-System Architecture
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
Simplified CPU Design
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.
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)
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.
Simplification of a Micro Code-
Driven Architecture
The Function Unit is the same as the ALUMemory M is RAM and ROM