process s address space linux address space
play

Processs Address Space Linux Address Space 0x7fffffff Stack Data - PDF document

10/21/2014 Processes, Address Spaces, and PROCESS Memory Management A running program and its associated data Jonathan Misurda jmisurda@cs.pitt.edu Processs Address Space Linux Address Space 0x7fffffff Stack Data (Heap) Data (Heap)


  1. 10/21/2014 Processes, Address Spaces, and PROCESS Memory Management A running program and its associated data Jonathan Misurda jmisurda@cs.pitt.edu Process’s Address Space Linux Address Space 0x7fffffff Stack Data (Heap) Data (Heap) Globals Text (Code) 0 Operating Systems • Manage Resources • Abstract Details MEMORY MANAGEMENT 1

  2. 10/21/2014 Allocation Strategies Allocation Strategies Continued • First fit • Worst fit – Find the first free block, starting from the beginning, – Find the free block with the most left over after that can accommodate the request fulfilling the allocation request • Next fit • Quick fit – Find the first free block, starting where the last search – Keep several lists of free blocks of common left off, that can accommodate the request sizes, allocate from the list that nearest matches the request • Best fit – Find the free block that is closest in size to the request Bitmaps Minimal Units of Allocation • Break memory up into fixed sized chunks Memory regions • Easier to manage A B C D 8 16 24 32 • Need less entries in bitmap 11111100 00111000 01111111 11111000 Bitmap • When memory from OS, chunk called a Page • When chunk of disk: Block Reclaiming Freed Memory Linked Lists A B C D A X B A B 8 16 24 32 A X A Memory regions X B B A 0 6 ‐ 6 4 B 10 3 ‐ 13 4 C 17 9 X D 26 3 ‐ 29 3 2

  3. 10/21/2014 Where Do We Store the Nodes? Buddy Allocation Allocation of size 2 in a region of size 16 Stack Size 16 $sp Unallocated Size 8 Size 8 Space brk Size 4 Size 4 Size 8 Heap Size 2 Size 2 Size 4 Size 8 _end Globals Size 2 Size 2 Size 4 Size 8 Buddy Allocation Buddy De ‐ Allocation Free region of size 2 in a region of size 16 Allocation of size 4 in a region of size 16 Size 2 Size 2 Size 4 Size 8 Size 2 Size 2 Size 4 Size 8 Mark region as free Size 2 Size 2 Size 4 Size 8 Size 2 Size 2 Size 4 Size 8 Combine with “buddy” Size 4 Size 4 Size 8 Buddy De ‐ Allocation Buddy Location Free region of size 1 in a region of size 16 • Given an allocation at address addr , where is its buddy? Size 4 Size 4 Size 8 • In the previous example, we had two buddies of Mark region as free size 4 at addresses 0 and 4 Size 4 Size 4 Size 8 • Since we always halve our space, we can force all of our sizes to be powers of 2. Combine with “buddies” • Then our two buddies only differ by 1 bit in their number Size 8 Size 8 buddy = addr ^ size Size 16 3

Recommend


More recommend