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

process s address space linux address space
SMART_READER_LITE
LIVE PREVIEW

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)


slide-1
SLIDE 1

10/21/2014 1 Processes, Address Spaces, and Memory Management

Jonathan Misurda jmisurda@cs.pitt.edu

PROCESS

A running program and its associated data

Process’s Address Space

Stack Data (Heap) Text (Code) 0x7fffffff Data (Heap) Globals

Linux Address Space Operating Systems

  • Manage Resources
  • Abstract Details

MEMORY MANAGEMENT

slide-2
SLIDE 2

10/21/2014 2

Allocation Strategies

  • First fit

– Find the first free block, starting from the beginning, that can accommodate the request

  • Next fit

– Find the first free block, starting where the last search left off, that can accommodate the request

  • Best fit

– Find the free block that is closest in size to the request

Allocation Strategies Continued

  • Worst fit

– Find the free block with the most left over after fulfilling the allocation request

  • Quick fit

– Keep several lists of free blocks of common sizes, allocate from the list that nearest matches the request

Bitmaps

A B C D

11111100 00111000 01111111 11111000

8 16 24 32 Memory regions Bitmap

Minimal Units of Allocation

  • Break memory up into fixed sized chunks
  • Easier to manage
  • Need less entries in bitmap
  • When memory from OS, chunk called a Page
  • When chunk of disk: Block

Linked Lists

A B C D Memory regions

A 6 ‐ 6 4 B 10 3 ‐ 13 4 C 17 9 ‐ 29 3 D 26 3

8 16 24 32

Reclaiming Freed Memory

A X B A X X B X A B A B

slide-3
SLIDE 3

10/21/2014 3

Where Do We Store the Nodes?

_end brk $sp Stack Heap Globals Unallocated Space

Buddy Allocation

Size 16 Size 4 Size 4 Size 8 Size 8 Size 8 Size 2 Size 2 Size 4 Size 8 Size 2 Size 2 Size 4 Size 8

Allocation of size 2 in a region of size 16

Buddy Allocation

Size 2 Size 2 Size 4 Size 8

Allocation of size 4 in a region of size 16

Size 2 Size 2 Size 4 Size 8

Buddy De‐Allocation

Size 4 Size 4 Size 8 Size 2 Size 2 Size 4 Size 8 Size 2 Size 2 Size 4 Size 8

Free region of size 2 in a region of size 16 Mark region as free Combine with “buddy”

Buddy De‐Allocation

Size 4 Size 4 Size 8

Free region of size 1 in a region of size 16 Mark region as free Combine with “buddies”

Size 4 Size 4 Size 8 Size 16 Size 8 Size 8

Buddy Location

  • Given an allocation at address addr, where is its

buddy?

  • In the previous example, we had two buddies of

size 4 at addresses 0 and 4

  • Since we always halve our space, we can force all
  • f our sizes to be powers of 2.
  • Then our two buddies only differ by 1 bit in their number

buddy = addr ^ size