Operating Systems Chapter 4: Memory Management E 4.1 Basic memory management 4.2 Swapping(交换) 43 irtual memory(虚拟内存) H 4.4 Page replacement algorithms H 4.5 Design issues for paging systems E 4.6 Implementation issues 47 Segmentation(分段) Gao Haichang, Software School, Xidian University 13
Operating Systems Gao Haichang , Software School, Xidian University 13 Chapter 4: Memory Management 4.1 Basic memory management 4.2 Swapping (交换) 4.3 Virtual memory (虚拟内存) 4.4 Page replacement algorithms 4.5 Design issues for paging systems 4.6 Implementation issues 4.7 Segmentation (分段)
Operating Systems Swapping g Sometimes there is not enough main memory to hold all the currently active processes g Two general approaches to memory management: H Swapping, bringing in each process in its entirety, running it for a while then putting it back on the disk I Virtual memory, allow programs to run even when they are only partially In main memory Gao Haichang, Software School, Xidian University 14
Operating Systems Gao Haichang , Software School, Xidian University 14 Swapping Sometimes there is not enough main memory to hold all the currently active processes. Two general approaches to memory management: Swapping, bringing in each process in its entirety, running it for a while, then putting it back on the disk. Virtual memory, allow programs to run even when they are only partially in main memory
Operating Systems Swapping (1) Time C B B B D D D Operating Operating Operating Operating Operating Operating Operating st system system system system (f) e Memory allocation changes as: H processes come into memory H leave memory c Shaded regions are unused memory Addresses amust be relocated since it is now at a different location g Hole, memory compaction. c Difference between fix and the variable partition School, xidian University Gao Haichang, Software 15
Operating Systems Gao Haichang , Software School, Xidian University 15 Swapping (1) Memory allocation changes as: processes come into memory leave memory Shaded regions are unused memory. Addresses A must be relocated since it is now at a different location. Hole, memory compaction. Difference between fix and the variable partitions
Operating Systems Swapping(2) B-Stack growth Room for growth B-Data B Actually in use B-Program A-Stack Room for growth Room for growth ==L=== A-Data Actually in A-Program Operating Operating system stem Allocating space for growing data segment G Allocating space for growing stack data segme ent Gao Haichang, Software School, Xidian University 16
Operating Systems Gao Haichang , Software School, Xidian University 16 Swapping (2) Allocating space for growing data segment Allocating space for growing stack & data segment
Operating Systems Memory Management with Bit Maps 8 16 1111000 P|o5|十[53巴a+-p44 1111111 1100111 111110 回2回2型 Hole Starts Length Process at 18 (b) c()Part of memory with 5 processes, 3 holes H tick marks show allocation units w shaded regions are free G(b) Corresponding bit map (shortcoming: searching a bitmap for a run of a given length is a slow operation). G(c) Same information as a list. Gao Haichang, Software School, Xidian University 17
Operating Systems Gao Haichang , Software School, Xidian University 17 Memory Management with Bit Maps (a) Part of memory with 5 processes, 3 holes tick marks show allocation units shaded regions are free (b) Corresponding bit map (Shortcoming: searching a bitmap for a run of a given length is a slow operation). (c) Same information as a list