Memory l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 24

Memory PowerPoint PPT Presentation


  • 141 Views
  • Uploaded on
  • Presentation posted in: General

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.

Download Presentation

Memory

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 l.jpg

Memory

Memory Management

(General Principles)


Memory management l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

Swap

  • Why ?

  • Who should be swapped?

  • When ?

  • Need of dynamic binding (and dynamic loading)

Operating Systems Memory Management


Single partition allocation l.jpg

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 l.jpg

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 l.jpg

Dynamic Binding Using Relocation Register

Main

Memory

14000

Base register

Physical

address

Logical address

CPU

+

14346

346

Operating Systems Memory Management


Multiple partition allocation l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

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 l.jpg

Page #

Frame#

0

1

2

3

4

5

6

0a

1b

2c

3d

4e

5f

6g

7h

8I

9j

10k

11l

12m

13n

14o

15p

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 l.jpg

Paging Hardware

Physical

Memory

Physical address

Logical address

CPU

p

d

f

d

Page table

f

Operating Systems Memory Management


Paged segmentation l.jpg

Paged Segmentation

User’s view of memory

Subroutines

Main

Program

Stack

Data

Operating Systems Memory Management


Memory management with segmentation l.jpg

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 l.jpg

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 l.jpg

Summary of Chapter

  • We mainly are concerned with these issues :

    • Time

    • Utilization of memory:fragmentation

    • User convenience:sharing, segmentation

    • Protection.

Operating Systems Memory Management


  • Login