1 / 28

Introduction to Computer Systems

Introduction to Computer Systems. 15-213 “ The Class That Gives CMU Its Zip! ”. Topics: Theme Four great realities of computer systems Chap 1 in “ Computer Systems ” book. And gives Ithaca??. Course Theme. Abstraction is good, but don ’ t forget reality!

foleyj
Télécharger la présentation

Introduction to Computer Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computer Systems 15-213 “The Class That Gives CMU Its Zip!” • Topics: • Theme • Four great realities of computer systems • Chap 1 in “Computer Systems” book And gives Ithaca??

  2. Course Theme • Abstraction is good, but don’t forget reality! • Courses to date emphasize abstraction • Abstract data types (e.g., Comp 220) • Asymptotic analysis (e.g., Comp 311) • These abstractions have limits • Especially in the presence of bugs • Need to understand underlying implementations • Don’t believe what Ali says

  3. Course Theme • Useful outcomes • Become more effective programmers • Able to find and eliminate bugs efficiently • Able to tune program performance • Prepare for later “systems” classes • Programing Languages, Operating Systems, Computer Networks, Complex Systems

  4. The Changes in Computing

  5. Great Reality #1 • Information is Bits + Context • Examples Source Program: #include <stdio.h> int main() { printf(“hello world\n”); } ASCII representation of the source program (text file): # i n c l u d e <sp> 105 110 99 108 117 100 101 32 < s t d i o . h > 115 116 100 105 111 46 104 62 Etc…. Actual representation on the disk: 00100011 01101001 01100011 01101100 01110101 01100100 …

  6. All information is represented as bits • Including disk files, programs in memory, user data in memory, data transferred across the internet, … • The only thing that distinguishes data objects is context • Same bits may represent an integer, floating-point number, character string, or machine instruction.

  7. Great Reality #1 cont. • Int’s are not Integers, Float’s are not Reals • Examples (see testint.c on arda in /home/barr/Student/Examples/chap1) • Is x2 ≥ 0? • Float’s: Yes! • Int’s: • 40000 * 40000 --> 1600000000 • 50000 * 50000 --> ?? • Is (x + y) + z = x + (y + z)? • Unsigned & Signed Int’s: Yes! • Float’s: • (1e20 + -1e20) + 3.14 --> 3.1 • 1e20 + (-1e20 + 3.14) --> ?? see Student/examples/testInt.c -1794967296 see Student/examples/testFloat.c 3.140000

  8. Computer Arithmetic • Does not generate random values • Arithmetic operations have important mathematical properties • Cannot assume “usual” properties • Due to finiteness of representations • Integer operations satisfy “ring” properties • Commutativity, associativity, distributivity • Floating point operations satisfy “ordering” properties • Monotonicity, values of signs

  9. Computer Arithmetic • Observation • Need to understand which abstractions apply in which contexts • Important issues for compiler writers and serious application programmers

  10. Great Reality #2 • You’ve got to know assembly • Chances are, you’ll never write program in assembly • Compilers are much better & more patient than you are • Understanding assembly key to machine-level execution model • Behavior of programs in presence of bugs • High-level language model breaks down • Link-time errors hard to find • Tuning program performance • Understanding sources of program inefficiency • Avoiding security holes • Example: buffer overflow bugs • Implementing system software • Compiler has machine code as target • Operating systems must manage process state

  11. Compilers • Programs are translated by other programs into different forms • A C program in text-file format must be translated in a low-level binary format • Humans can read the text-file • Computers can read the binary • Assembly is (basically) a human readable form of binary • Translate source to binary in Unix by compiler driver: unix> gcc –o hello hello.c

  12. Compilers Translation phases: • Preprocessing phase. The preprocessor (cpp) modifies the original C program according to directives that begin with #hello.chello.i • Compilation phase. The compiler (ccl) translates the text file into a different text file containing an assembly level file.hello.i hello.s • Assembly phase. The assembler (as) translates the assembly file into a machine language (binary) format. hello.s  hello.o • Linking phase. The linker (ld) merges separately compiled files, libraries (like stdio), etc. into an executable object file that can be loaded into memory and run. hello.0 printf.o  hello

  13. Compilers Translation phases: • figure 1.3 printf.o Pre- processor (cpp) Compiler (cc1) Assembler (as) Linker (ld) hello.c hello.i hello.s hello.o hello Source program (text) Assembly program (text) Modified source program (text) Relocatable object programs (binary) Executable object program (binary)

  14. Executing programs • Processors only understand binary programs • The hello.c program has been translated to the executable object file hello and stored on disk • To run, we type the program’s name: unix> ./hello hello world unix> • A shell loads and runs the program.

  15. Executing programs • Organization • To understand how the program is run, must understand how the hardware is organized.

  16. Executing programs • Motherboard • Contains the processor, RAM, cache, bus interface

  17. Executing programs • CPU • The “brains”

  18. Executing programs • Organization • We create abstract models of the hardware.

  19. Executing programs • Buses. Carry a number of bytes of information between components. • The number is a fundamental system parameter called a word. • Example: Pentium word = 4 bytes; i7core = 8 bytes; embedded controllers = 1 or 2 bytes.

  20. USB controller Graphics adapter Disk controller Disk Executing programs • I/O Devices. The system’s connection to the external world. • Example: keyboard, mouse, display, disk drive • Connected to the I/O bus by either a controller or an adapter. • Controllers are chip sets in the device or on the motherboard. • Adapter is a card that plugs into a slot on the motherboard.

  21. Executing programs • Main Memory. A temporary storage device that holds both a program and the data it manipulates. • Consists of a collection of Dynamic Random Access Memory (RAM) chips. • Logically organized as a linear array of bytes, each with a unique address. • Instructions and data will take up a variable number of bytes in RAM. Main memory

  22. Executing programs • The central processing unit (CPU). The engine that interprets (or executes) instructions stored in main memory. • Consists of many electronic devices and small pieces of memory (registers): • Control unit (CU) • Arithmetic/Logic Unit (ALU) • Program counter (PC) register that points at next instruction in main memory. • Other general and special purpose registers. CU

  23. Executing programs The central processing unit (CPU). Continued. • Performs the same basic tasks over and over again in a cycle (called the execution cycle) • Fetch the next instruction from main memory • Decode (or interpret) the bits in the instruction • Executes the instruction • Update the PC to point at the next instruction • There are only a few simple operations (or instructions) that a processor can execute

  24. CPU Register file ALU PC System bus Memory bus Main memory "hello" Bus interface I/O bridge Expansion slots for other devices such as network adapters I/O bus USB controller Graphics adapter Disk controller Mouse Keyboard Display Disk User types "hello" Executing programs • Putting it all together: running the hello program • When we type “./hello” the shell program reads each character and stores each into memory.

  25. CPU Register file ALU PC System bus Memory bus Main memory "hello,world\n" Bus interface I/O bridge hello code Expansion slots for other devices such as network adapters I/O bus USB controller Graphics adapter Disk controller Mouse Keyboard Display hello executable stored on disk Disk Executing programs Putting it all together: running the hello program • When we hit the enter key, the shell loads the executable hello file by executing a sequence of instructions that copies the code and data from the disk to the memory. Uses DMA to bypass the CPU

  26. Executing programs • Putting it all together: running the hello program • Now the CPU begins executing the instructions in the hello program. • The program instructions copy the bytes in the string “hello world\n” from memory to the register file, • then from there to the display device. • The device displays the string on the screen. • See next slide.

  27. Running the hello program CPU Register file ALU PC System bus Memory bus Main memory "hello,world\n" Bus interface I/O bridge hello code I/O bus Expansion slots for other devices such as network adapters USB controller Graphics adapter Disk controller Mouse Keyboard Display Disk hello executable stored on disk "hello,world\n"

  28. Example • See: http://courses.cs.vt.edu/csonline/MachineArchitecture/Lessons/CPU/index.html Much simpler than the IA32 architecture. Does not make the register file explicit. Uses an accumulator (not in IA32).

More Related