memory
Download
Skip this Video
Download Presentation
Memory

Loading in 2 Seconds...

play fullscreen
1 / 24

Memory - PowerPoint PPT Presentation


  • 185 Views
  • Uploaded on

Memory . Memory Management (General Principles). Memory Management. Objectives User believes he is the unique user of the all space. User’s address space is infinite. Realities Many users share the memory. A program consists of modules written by many. Primary memory has limited size.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Memory' - donoma


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
memory

Memory

Memory Management

(General Principles)

memory management
Memory Management
  • Objectives
    • User believes he is the unique user of the all space.
    • User’s address space is infinite.
  • Realities
    • Many users share the memory.
    • A program consists of modules written by many.
    • Primary memory has limited size.
    • Second memory is 1 to 2 order cheaper than p.m.

Operating Systems Memory Management

multi step processing of a user program
Multi-step Processing of a User Program
  • Linking : unifying addresses from different modules
  • Binding : changing addresses in user’s program to real ones logical address ---> physical address
  • Loading: putting the program into memory
  • Executing the program

Should linking, binding, and loading be always done in this order

Operating Systems Memory Management

when to bind
When to Bind ?
  • During compile time
    • Need to know the precise memory allocation
    • Only work for small simple programs
  • During load time
    • The program cannot be moved around during execution
    • Simple but inconvenient
  • During execution time
    • The program can be moved around during execution
    • Run-time overhead => hardware assistance

Operating Systems Memory Management

overlays
Overlays
  • Enhancing memory availability
  • Better having dynamic loading and binding

Overlay driver

Frequently used routines

Main Memory

Overlay driver

Routine A

Frequently used routines

Routine B

Application

Operating Systems Memory Management

slide6
Swap
  • Why ?
  • Who should be swapped?
  • When ?
  • Need of dynamic binding (and dynamic loading)

Operating Systems Memory Management

single partition allocation
Single-Partition Allocation
  • Basic idea: allocate the entire memory to ONE process
    • Simple, minimum cost
    • User has maximum flexibility
    • No service from OS
    • No multiprogramming

Operating Systems Memory Management

a better idea
A better Idea
  • Allocate the memory to O.S and one process
    • Some service from OS
    • Still no multi-programming
    • An issue : where to put O.S ?

O.S

Answer : Put O.S in lower end :

Reasons:

- Interrupt vector

- memory expansions

User Program

& Data

Operating Systems Memory Management

dynamic binding using relocation register
Dynamic Binding Using Relocation Register

Main

Memory

14000

Base register

Physical

address

Logical address

CPU

+

14346

346

Operating Systems Memory Management

multiple partition allocation
Multiple-Partition Allocation
  • Basic Idea: allocating memory to multiple processes
  • Two ways :
    • Fixed-size partition
      • Memory is divided into several parts of fixed size
      • Each process takes one part
      • No longer in use
    • Variable-size partition
      • Memory is partitioned dynamically
      • O.S. keeps a table of parts of memory available
      • When a process arrives, OS searches for a part of memory large enough for the process

Operating Systems Memory Management

example
Example

OS

Job Queue

400K

process

mem. req.

finish time

P1

600K

10

P2

1000K

5

P3

300K

20

2160K

P4

700K

8

P5

500K

15

2560K

Operating Systems Memory Management

example cont d

OS

OS

OS

OS

400K

400K

400K

400K

P1

P1

P1

1000K

P4

P4

P2

2000K

P3

P3

P3

P3

2300K

P1

600K

10

P2

1000K

5

P3

300K

20

P4

700K

8

P5

500K

15

Example (cont’d)

OS

400K

P5

P2

terminates

Allocate

P4

P1

terminates

Allocate

P5

P4

P3

Job Queue

process

mem. req.

finish time

Operating Systems Memory Management

dynamic allocation problem
Dynamic Allocation Problem
  • Basic strategies:
    • First-fit : allocate the first hole that is big enough.
    • Best-fit: allocate the smallest hole that is big enough.
    • Worst-fit: allocate the largest hole that is big enough
  • Usually, first-fit is fastest and both first-fit and best fit perform better than worst-fit.
  • Any other problems? (To be discussed)
    • Protection
    • Fragmentation

Operating Systems Memory Management

slide14

Protectionin Multiple-Partition (Variable Size)

Limit register

Base register

Main

Memory

4096

14000

Physical

address

Logical

address

CPU

<

+

346

14346

Operating Systems Memory Management

fragmentation the free memory space is broken into little pieces
FragmentationThe free memory space is broken into little pieces
  • Internal fragmentation
    • Definition : difference between required memory and allocated memory.
    • Cause:estimation error, management overhead.
  • External fragmentation
    • Definition : scattered small pieces not allocated
    • Solution: compaction
    • Compaction strategy

Operating Systems Memory Management

t ways to compact memory

P1

P1

P1

P2

P2

P2

P3

P3

P3

900K

900K

P4

P4

P4

#t Ways to Compact Memory

OS

OS

OS

OS

300K

P1

500K

P2

600K

400K

800K

1000K

1000K

P3

1200K

300K

1500K

900K

P4

1900K

200K

2100K

Moved 600K

Moved 400K

Moved 200K

Original

Operating Systems Memory Management

paging
Paging
  • A compactingless memory management
    • No external fragmentation
  • A compromise between fixed-size partition and variable-size partition: less internal fragmentation than fixed-size partition

Operating Systems Memory Management

paging how
Paging (How)
  • Memory is divided into frames of fixed small size
  • A process is allocated a number of frames as it needs
  • Implementation
    • Divide logical memory into pages.
    • A dynamic mapping (binding/relocation) between pages and frames

Operating Systems Memory Management

slide19

Page #

Frame#

0

1

2

3

4

5

6

0 a

1 b

2 c

3 d

4 e

5 f

6 g

7 h

8 I

9 j

10 k

11 l

12 m

13 n

14 o

15 p

Frame#

Page#

0

0 5

1 6

2 1

3 2

i

j

k

l

1

m

n

o

p

2

Page table

3

Logical Memory

a

b

c

d

e

f

g

h

Operating Systems Memory Management

paging hardware
Paging Hardware

Physical

Memory

Physical address

Logical address

CPU

p

d

f

d

Page table

f

Operating Systems Memory Management

paged segmentation
Paged Segmentation

User’s view of memory

Subroutines

Main

Program

Stack

Data

Operating Systems Memory Management

memory management with segmentation
Memory Management with Segmentation
  • Memory allocation
    • Fixed-size partition
    • Variable-size partition
      • The problem still exists
    • Paging: paged segmentation system

Operating Systems Memory Management

paged segmentation system
Paged Segmentation System
  • Aim:taking the advantages of both paging and segmentation system
  • Implementation : treat each segment independently, each segment has a page table
  • Logical address consists of three parts:
    • Segment#
    • Page #
    • Offset
  • Dynamic address translation,

Operating Systems Memory Management

summary of chapter
Summary of Chapter
  • We mainly are concerned with these issues :
    • Time
    • Utilization of memory:fragmentation
    • User convenience:sharing, segmentation
    • Protection.

Operating Systems Memory Management

ad