Sie sind auf Seite 1von 1

● Memory Layout

○ Stack (grows backwards), Heap, Static Data, Literals, Instructions


● Buffer - Used to store data temporarily
○ Keep track of the Caller vs. Callee Frame
○ C doesn’t keep track of array bounds, so we have to
○ Buffer Overflow occurs when you write past the bounds of a buffer
○ By overflowing, you can overwrite other data (kind of hacking) via
■ Stack Smashing
■ Code Injection
○ Avoid Buffer Overflow via:
■ System Level Protections (Non executable code segments, randomized
stack offsets)
■ Avoid overflow vulnerabilities (Limit String lengths, don’t use C)
■ Use Stack Canaries (Place value just beyond buffer, check for existence)
● Binary Units/Prefixes
○ X * 2​abc​bytes = 2​log2(x) + abc​ (how to calculate prefixes)
● Caches
○ Processor Memory Bottleneck means that Performance is suffering
○ Solve with caches - a “pantry to limit trips to the grocery store”
■ Based on temporal and spatial locality, can be hit or miss
■ Take advantage of locality and memory hierarchy to write efficient
programs
○ Average Memory Access Time = Hit Time + Miss Rate * Miss Penalty
○ Memory Hierarchies show which processes are costly vs. not costly
○ Organization
■ Block Size (number of bytes per set), Cache size (total number of bytes in
cache), Associativity (Number of sets per cache)
○ Addresses
■ Tag (check for match), Index (where in cache to look), offset (which byte
of block)
● Misses
○ Conflict Miss - First access
○ Compulsory Miss - Multiple data objects map to the same place
○ Capacity Miss - When working set > cache block
● Writes
○ Write Hit
■ Write Through - Immediately to next level
■ Write Back - Defer until next line is evicted
○ Write Miss
■ Write Allocate - Load into cache, then execute
■ No-Write Allocate - write immediately to next level
● Control Flow
○ CPU runs things concurrently but it looks simultaneous
○ fork() - parallel process, clones process at that moment in time
■ wait() used to force one process to wait for the other
● Virtual Memory
○ Ability to use limited RAM across multiple processes
○ Protection for each process without interference

Das könnte Ihnen auch gefallen