====== Computer Architecture Overview ====== ---- ===== What is an OS? ===== * "A program that acts as an intermediary between a user of a computer and the computer hardware." {{ :cs438:wheres_an_os.png?150 |}} ===== Two popular definitions for OS ===== * Bottom-up perspective: __resource manager/coordinator__, manage your computer’s resources * Top-down perspective: __hardware abstraction layer__, turn hardware into something that applications can use ===== What does hardware provide? ===== * Seen a glimpse of the functions OS provides * But what hardware does it have to work with to provide those functions? * Let's take a high level overview of how a typical computer system looks inside * Different platforms have different chips: phone, PC, your DVD player, etc. * But major concepts are the same ===== The x86 Platform ===== * Many processor architectures: Intel x86, ARM, Oracle Sparc, IBM Power, etc. * We’ll use x86 as an exemplar * The Android emulator uses an x86 Atom image * Familiarity. Lots of online resources. * Applies to most other architectures as well (with small differences) * Besides, most of the OS code we will encounter is architecture agnostic ===== Typical PC Architecture ===== * One or more CPUs, memory, and device controllers connected through system bus {{ :cs438:old_mb.png?350 |}} ===== Computer Organization ===== {{ :cs438:computer_organization.png?700 |}} ===== Computer Organization: Abstract Model ===== {{ :cs438:comp_org_abstract_model.png?600 |}} * I/O: communicating data to and from devices * CPU: digital logic for doing computation * Memory: N [[http://www.cs.uaf.edu/~cs301/notes/Chapter2/node2.html|words]] of B bits ===== The Stored Program Computer ===== {{ :cs438:stored_program_computer.png?600 |}} * Often called the [[https://en.wikipedia.org/wiki/Von_Neumann_architecture|"Von Neumann"]] architecture * Memory holds both __instructions__ and __data__ * CPU interprets instructions * Instructions read/write data * "Instructions" are [[https://en.wikipedia.org/wiki/X86_instruction_listings|CPU-level instructions]] ===== Memory Access ===== {{ :cs438:memory_access.png?600 |}} * Memory accesses are __synchronous__ * Instruction stalls while memory is fetched * Caches are used to reduce the performance hit ===== The Stack ===== {{ :cs438:stack.png?300 |}} * For implementing function calls * Temporary storage area * Saved register values, local variables, parameters * Stack grows "downward" on x86 ===== I/O Access ===== {{ :cs438:io_access.png?600 |}} * Similar to memory access * Except different control signals, so I/O devices know to respond (rather than memory) * IN, OUT instructions are also synchronous ===== Interrupts ===== * I/O instructions synchronous, but hardware devices can be slow * Reading from disk (milliseconds), waiting for a keystroke (hours?) * Should CPU stay idle when waiting for device? * Interrupts allow CPU to multitask while waiting * Allows I/O to be __asynchronous__ * Programmable Interrupt Controller (PIC) allows more than one device to interrupt CPU {{ :cs438:interrupts.png?600 |}} ===== Direct Memory Access ===== {{ :cs438:dma.png?600 |}} * DMA allows CPU to do useful work while transferring data between disk and memory * CPU programs (controls) DMA controller (or device directly) * DMA controller gets ownership of the bus * DMA controller produces mem read/write bus signals ===== Symmetric Multiprocessors (SMP) ===== {{ :cs438:smp.png?600 |}} * Initially, one CPU starts executing instructions to initialize system * Thereafter, each CPU executes independently * Only sharing is through common memory (data structures) * Each CPU receives interrupts independently through an APIC (Advanced PIC) ----