------------------------------------------------------ Session 29 - April 16, 2003 ------------------------------------------------------ AGENDA: 0 Admin 1 Ch. 4.1: Basic memory management 2 Ch. 4.2: Swapping ------------------------------------------------------ 0 - ADMIN ------------------------------------------------------ Everybody thoroughly confused about the test? :-) ------------------------------------------------------ 1 - CH 4.1 BASIC MEMORY MANAGEMENT ------------------------------------------------------ What are the characteristics of the ideal comp. memory? * how close to that do we get? * what are problems? Describe the memory hierarchy * In the context of the hierarchy, what would the memory manager do? Memory management approaches * keep processes in memory all the time * move processes back and forth between main memory and disk during execution (swapping and paging). Monoprogramming without swapping or paging * What does mono programming mean? * Fig 4-1 p. 310 * pros & cons Multiprogramming with fixed partitions * What does multiprogramming mean? * Fig 4-2 p. 311 * pros & cons Relocation * different jobs run at different addresses - how can the program be coded to reference the correct address for where it will be run, esp. when it is not known where it will be run? * could modify all instructions as loaded into memory to have the correct address - this is ugly, but can be done - what information would be needed to make this work? Protection problem * programs can access any memory address * Tanenbaum: "In multiuser systems, it is undesirable to let processes read and write memory belonging to other users." Hmm, delicately understated. * Proposed solutions? PSW key (process status word) Base and limit registers - solves relocation problem as well ------------------------------------------------------ 2 - CH 4.2 SWAPPING ------------------------------------------------------ With timesharing systems/personal computers, not always enough memory to hold everything that wants to run. * Possible solutions? - don't allow more to run than have memory - swapping (simplest) - virtual memory (not simplest) Swapping * Fig 4-3 p. 314 * Don't use fixed partitions - each partition is exactly the right size. - Possible problems? What if program needs more memory while running? - Fig 4-4 p. 315 What about creating unusable "holes" in memory? - could do memory compaction, but what is problem? Memory fragmentation: internal and external. * We are dealing with external fragmentation when deal with holes in memory. Wasted space within memory block allocated to a process is internal fragmentation. Memory management with bit maps * Fig 4-5 p. 316 * What is the ideal size block? - size of bitmap vs. wasted space in block * cost of finding correct size contiguous chunk using the bitmap Memory management with linked lists * Fig 4-6 p. 317 * Allocation algorithm suggestions? - first fit - next fit - continues search from where last ended - best fit - worst fit - quick fit COS 421 - Lecture Notes #29 SPRING 2003 COS421-lect-2003-04-16.doc Page 1 Printed 16.04.03