Swapping(2) B-Stack Room for growth Room for growth B-Data B Actually in use B-Program A-Stacl s Room for growth Room for growth A-Data Actually in A-Program Operating Operating system system Figure 3-5. (a) Allocating space for growing data segment. (b) Allocating space for growing stack, growing data segment Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 3-5. (a) Allocating space for growing data segment. (b) Allocating space for growing stack, growing data segment. Swapping (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Managing free memory Bit maps and linked lists Bitmap a Memory is divided into allocation units(a few word to KB) a Corresponding to each unit, there is a bit in the bitmap a Hard to find a given length free space
Managing free memory ◼ Bit maps and linked lists ◼ Bitmap ❑ Memory is divided into allocation units (a few word to KB) ❑ Corresponding to each unit, there is a bit in the bitmap ❑ Hard to find a given length free space
Memory Management with Bitmaps 8 16 11111000 P5|叫53巴as巴144 1111111 11001111 11111000 182 P206 P263 H293X Hole Starts Length Process at182 Figure 3-6.a)Apart of memory with five processes and three holes. The tick marks show the memory allocation units. The shaded regions(0 in the bitmap) are free. ( b)The corresponding bitmap (c) The same information as a list Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 3-6. (a) A part of memory with five processes and three holes. The tick marks show the memory allocation units. The shaded regions (0 in the bitmap) are free. (b) The corresponding bitmap. (c) The same information as a list. Memory Management with Bitmaps Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Memory Management with Linked Lists Before x terminates After X terminates (a)AX becomes A绕B (b)AX becomes A x⊥B becomes B becomes Figure 3-7. Four neighbor combinations for the terminating process, X Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 3-7. Four neighbor combinations for the terminating process, X. Memory Management with Linked Lists Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Manage free memor Linked list a Double linked list o How to allocate free memory to programs? First fit a quick; beginning used more often; break a large free space Next fit o every time from where last time used Best fit a Search entire list finds the hole close to the actual size Worst fit a Finds the largest hole Quick fit a Keeps separate queues of processes and holes
Manage free memory ◼ Linked list ❑ Double linked list ❑ How to allocate free memory to programs? ◼ First fit ❑ quick; beginning used more often; break a large free space ◼ Next fit ❑ Every time from where last time used ◼ Best fit ❑ Search entire list, finds the hole close to the actual size ◼ Worst fit ❑ Finds the largest hole ◼ Quick fit ❑ Keeps separate queues of processes and holes