* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download System Overview
Survey
Document related concepts
Transcript
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. 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 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) Hardware Computer-System Architecture Memory Memory Memory can be viewed in a hierarchical structure: REGISTERS volatile CACHE RAM non-volatile DISKS 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 sectors Within a sector the bit is the smallest data unit Sectors 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. User OS Programs HW OS in Relation to Other System Components Program Translators Compilers Assemblers Interpreters The Translation Process Lexical Analysis source program Parsing Code Generation 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. Mov b to register ax a = b + c; Add c to register ax Compiler Mov register ax to a High-level Source Code Compiler Object Library Object File Linker Object Library Executable File The Compilation and Linking Process 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 assign ::= id := <exp> 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 Compilers exp ::= <term> { + <term> | - <term> } Recursive-descent parse of an expression statement 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. mov ax,b Mov b to register ax add ax,c Add c to register ax mov a,ax Assembler Mov register ax to a 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. Mod R/M opcode 7 0 mod 7 6 reg r/m 543 210 immed-low 7 -- 0 immed-high 7 -- 0 disp-low 7 -- 0 disp-high 7 -- 0 (The opcode indicates whether or not the immediate v alue f ield is present, as well as its size.) Intel Instruction Format (8086/8088) Low-level Source Code Assembler Object Library Object File Linker Object Library Executable File The Assembly and Linking Process 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 Assign (temp, Add (b,c)) a = b + c; Interpreter Assign (a, temp) Interpreters The interpreter provides a virtual run-time environment A Java interpreter is called a “virtual machine” software p-code interpreter operating system hardware High-level Source Code Interpreter (translation mode) P-code Library P-code Library The Interpretation Process P-code File Interpreter (execution mode) 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 data Address bus for the address of a memory location or an I/O port Control bus for control signals (Interrupt request, memory read/write …) Each operation must be synchronized by the system clock Registers 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 Cycle Is 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) Microcode The 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 microcoded subroutine in control memory that “executes” the machine instruction. Simplification of a Micro CodeDriven Architecture The Function Unit is the same as the ALU Memory M is RAM and ROM