CSCE 312 Lecture 3

From Notes
Jump to navigation Jump to search

« previous | Tuesday, September 6, 2011 | next »


Oh well… I speak Korean better than you

Sample Program

// hello.c
#include <stdio.h>

int main() {
    printf("Hello\n");
    return 0;
}


Model of Computer (cont'd)

Direct Memory Access (DMA)

takes instruction from CPU to move data around

When loading program, DMA takes program from disk into memory, then sends an interrupt to the processor when complete.

By default, anything without units is interpreted as a byte (e.g. unit of memory)

Note: 1 word is 32 bits (4 bytes). Therefore, incrementing the PC usually means jumping 4 bytes in memory

CPU Components

ALU
computes data and addresses from ISA
suppose ISA has 16 instructions (4 bits to specify), one of which is add and takes 3 values for register addresses. If there are 32 registers, then an add instruction will be 19 bits: 4:instruction + 5:register + 5:register + 5:register


Memory Hierarchy

Data is moved in chunks (specified as labels for each destination)
  1. Registers (from Caches: 1 byte)
  2. Caches (L1-L3) (from Main Memory: 64 bytes; "cache block"
  3. Main Memory (from Disk: 512 KB; "page")
  4. Disk
  5. Network or Tape


Operating System

Software layer between program and hardware

OS Hardware Abstractions

  • file: disk (I/O)
  • virtual memory: main memory + disk
  • process: processor + main memory + disk

Process

a running program

Multiple processes can run at the same time, but CPU can only focus on one instruction at a time (illusion of concurrency)

"Concurrency" possible with context switching (restoring registers and PC to a certain process's execution state)