Friday, October 22, 193 Today: Paging (see notes dated 931015 for start of discussion) ------------------------------------------------------------------------------- - Paging has *no* external fragmentation (all pages are same size so any free page can be assigned to any process that needs it) - internal fragmentation --- especially last page. Average of 1/2 page internal fragmentation per process. Smaller pages reduce fragmentation but create more pages - overhead in managing pages - generally large number of pages so can't use registers - avoid two memory accesses per memory access by use of hardware - associative registers or translation look-aside buffers (TLBs) - expensive but fast in looking up value - size in 10s of entries, not 1000s (22 on 68030; 32 in 80486) - associative registers: when key matched outputs value - all entries examined in parallel - cache page number/frame number in associative registers - when not found go examine page table (hit ratio) - Sharing pages (reentrant code) - reentrant code == pure code: non-self-modifying code that never changes during execution - code pages shared among all processes - data separated out with one copy per process - Note that user's view of memory is as one contiguous dedicated space - actual physical memory has user's program scattered throughout physical memory, shared with other processes - in other words, separation of logical and physical addresses - note that size of logical and physical address spaces decoupled (hence size of addresses). Here logical <= physical. Later consider logical > physical. - OS also needs to map logical addresses to physical addresses ------------------------------------------------------------------------------- Segmentation: - separating (logical) memory into different portions (segments) for different purposes - segment has name (e.g., a unique number) and length - addresses refer to segment name and offset within segment - block structured program might have segments for globals, call stack and activation records, dynamically allocated variables, code - process' *segment table* implements segments in physical memory - user addresses - each entry is base/limit pair - address must fall within 0..limit for named segment - os trap if out of range---addressing error - protection can be implemented (read-only for code, read/write for data) - sharing---same segment appears in segment table for multiple processes - segments are variable size so external fragmentation can result ------------------------------------------------------------------------------- Paging + Segmentation (Paged Segmentation) - each segment has its own page table - logical address in three parts - segment number (name) - page number within segment - offset within page - implementation: segment table has base address for page table - look up in page table - get physical address in return ------------------------------------------------------------------------------- Very large number of segments (MULTICS) - also page segment table - segment number is into segment table - find proper page in segment table and get the address of process' page table - page table entry points to physical page ------------------------------------------------------------------------------- Next: Chapter 8