COMP 3511: Lecture 2
Date: 2024-09-29 21:40:37
Reviewed:
Topic / Chapter: Interrupts & Storage
summary
❓Questions
Notes
Interrupts
-
IO
- IO device & CPU: execute concurrently & asynchronously
- ~= event driven?
- each device controller: in charge of a particular device
- w/ local buffer
- responsible for moving data between:
- peripheral devices it control
- & local buffer storage
- IO operation: from device -> local buffer of controller
- CPU: moves data from/to main memory local buffers
- typically: for slow devices (keyboard, mouse)
- DMA controller: to move data for fast devices (e.g. disks)
- device controller: informs CPU operation termination (completion / fail) by: interrupt
- i.e. requires CPU attention
- for input: i.e. data is available in local buffer
- for output: i.e. IO operation has been completed
- IO device & CPU: execute concurrently & asynchronously
-
Interrupt cycle
-
Interrupt timeline
- CPU & device: execute concurrently
- IO device: may trigger interrupt by sending CPU a signal
- CPU handles interrupt (i.e. transfer control to interrupt handler)
- then returns to interrupted instruction
-
Interrupt functions
- interrupts: widely used in modern OS systems
- for asynchronous event handling
- e.g. device controllers hardware faults
- all modern OS: interrupt-driven
- hundreds of interrupts occur per sec
- CPU: extremely fast ()
- hundreds of interrupts occur per sec
- interrupt: transfers control to:
- interrupt service routine / interrupt handler
- part of kernel code; OS runs to handle a specific interrupt
- also: implements a interrupt priority levels
- high-priority interrupt: can preempt execution of low-priority
- trap / exception: SW-generated interrupt caused either by:
- error (e.g. div by 0) / user request (e.g. some syscall)
- interrupts: widely used in modern OS systems
Storage
-
Bits & Units
- bit: basic unit of computer storage (0/1)
- byte: 8 bits
- smallest chunk of storage from most computers
- word: computer architecture's native unit of data
- nowadays: mostly
1 word = 8 byte = 64 bits
- nowadays: mostly
- larger units
- kilobyte bytes
- megabyte bytes
- gigabyte bytes
- terabyte bytes
- petabyte bytes
- often rounded up in for computer manufacturers
- however, network measurements: given in bits, not bytes
-
Storage hierarchy
- storage systems: organized in hierarchy
- w/ speed, cost / unit, capacity, and volatility (non-volatile vs. volatile)
- usually, higher: faster & more expensive, but smaller & more volatile
- storage systems: organized in hierarchy
-
Memory
- main memory: directly accessible by CPU
- only large storage media to be so
- volatile, often random-access memory
- in the form of: dynamic ram (DRAM)
- basic operations:
load
&store
to specific memory address- that is: byte addressable
- each addr: refers to 1 byte in memory
- computers: also use other forms of memory
- main memory: directly accessible by CPU
-
Second storage
- i.e. extension of main memory
- w/ non-volatile storage capacity
- data: stored permanently
- most common such storage:
- hard disk drives (HDD)
- nonvolatile memory (NVM) devices
- provides storage for both programs & data
- generally: two types
- mechanical
- HDDs, optical disks, holographic storage, magnetic tape
- generally larger & less expensive
- electrical
- flash memory, SDD, FRAM, NRAM
- electrical: often referred as NVM
- typically costly, smaller, more reliable & faster
- mechanical
-
Caching
- important: performed at many levels in computers
- for memory, address translation, file blocks, file names (freq. used), file dir, network routes, etc.
- ⭐ fundamental idea: a subset of information: copied from slower to a faster storage temporarily
- i.e. make freq. used case: faster
- access: first check whether information is inside cache
hit
: inside cache; information can be directly retrieved (fast)miss
: not inside cache; data copied from slower storage to cache, then used (slow)
- cache: usually much smaller than storage (memory) being cached
- cache management: cache size & replacement policy
- major criteria: cache hit ratio; percentage of hit per access
- important measurement
- important: performed at many levels in computers
-
Locality: principle below caching
- temporal locality (in time)
- recently accessed items: likely to be accessed again
- spatial locality (in space)
- contiguous blocks (i.e. neighbor of recently accessed): likely to be accessed shortly
- without locality pattern (i.e. all item: accessed w/ equal prob): cache can't work
- temporal locality (in time)