April 26th Lecture ==================== address space - a range of memory locations, each with an address (Note: for simplicity, we'll use byte addressing rather than word addressing for all examples) How many bits in an address? N bits = 2^N unique addresses N=2: 4 addresses (00, 01, 10, 11) N=32: ~4 billion Terminology: "4 GB address space" (size of space) "32-bit address space" (size of address) (same thing if word size = 1 byte) Note 2^10 = 1024 (which is ~1000). So: 2^10 ~= 1 thousand 2^20 ~= 1 million 2^30 ~= 1 billion ... We can quickly estimate any power of 2 if we memory 2^1 through 2^9 and combine with the above. 2^27 = 2^7 * 2^20 = 128 * 1 million =~ 128 million 2^49 = 2^9 * 2^40 = 512 * 1 trillion =~ 512 trillion 1K in computer terms usually refers to 1024 (not 1000)...except for hard drive manufacturers who want to make it sound like you're getting more than you really are. - some standards bodies insist that we call 1024 a "kibibyte" rather than kilobyte and 2^20 a "mebibyte" rather than a megabyte...of course few people pay any attention to this [= Memory Allocation =] Fixed Partition: * equal size paritions - lots of wasted space (a partition has to be large enough to hold the largest program...but most programs don't need this much memory * unequal size partitions - how do we assign programs to partitions? Queue for best fit? Or take best fit that's open right now (with extra waste)? * general problem with either partition scheme: internal fragmentation (i.e., wasted space *inside* the allocated chunks of memory) Dynamic Partitioning: * break memory into many tiny blocks, give each process multiple contiguous blocks * track open blocks: bitmap or linked list? - bitmap: very memory efficient, but searching is expensive - linked list: more resource usage, but faster to search * still need algorithms to fine exactly where to put a process - first fit/next fit - best fit - worst fit * external fragmentation (wasted space *outside* the allocated chunks of memory...tiny holes not big enough to hold any program) Paging: * partition programs into pages * partition physical memory into frames * page size = frame size * simple paging: all pages are loaded at once * key idea: pages can be non-consecutive in memory +----+----+----+----+----+----+ | P1 | P1 | P2 | P1 | P2 | P2 | +----+----+----+----+----+----+ * no internal fragmentation * a little external fragmentation when space of last page isn't completely filled Address translation is more complicated now; no longer 1 physical address for whole program; use a page table to translate logical addresses to physical addresses.