copyright © genetic computer school 2008 computer systems architecture sa 7- 0 lesson 7 memory...

20
SA 7- 1 Copyright © Genetic Computer School 2008 Computer Systems Architecture Lesson 7 Memory Management

Upload: irene-davis

Post on 17-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 1Copyright © Genetic Computer School 2008

Computer Systems Architecture

Lesson 7

Memory Management

Page 2: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 2Copyright © Genetic Computer School 2008

Computer Systems Architecture

LESSON OVERVIEW

areas of memory managementMemory and storage managementMemory management in virtual systemsAddress translation mechanismsMemory management problemsManual memory managementAutomatic memory management

Page 3: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 3Copyright © Genetic Computer School 2008

Computer Systems Architecture

Areas Of Memory Management

Memory management is usually divided into three areas:

Hardware

Operating system

Application

Page 4: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 4Copyright © Genetic Computer School 2008

Computer Systems Architecture

Hardware Memory Management

Memory management at the hardware

level is concerned with the electronic

devices that actually store data.

This includes things like RAM and

memory caches.

Page 5: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 5Copyright © Genetic Computer School 2008

Computer Systems Architecture

Operating System Memory Management

In the operating system, memory must be

allocated to user programs, and reused by

other programs when it is no longer required.

The operating system can pretend that the

computer has more memory than it actually

does, and also that each program has the

machine's memory to itself.

Page 6: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 6Copyright © Genetic Computer School 2008

Computer Systems Architecture

Application Memory Management_1

It involves supplying the memory needed for a program's objects and data structures from the limited resources available, and recycling that memory for reuse when it is no longer required. Because application programs cannot in general predict in advance how much memory they are going to require, they need additional code to handle their changing memory requirements.

Page 7: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 7Copyright © Genetic Computer School 2008

Computer Systems Architecture

Application Memory Management_2

Application memory

management combines

two related tasks:

Allocation

Recycling

Page 8: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 8Copyright © Genetic Computer School 2008

Computer Systems Architecture

Application Memory Manager

CPU overhead

Interactive pause times

Memory overhead

Page 9: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 9Copyright © Genetic Computer School 2008

Computer Systems Architecture

Memory In Computer System

Virtual memory

High-speed cache

Main memory

Secondary memory

Page 10: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 10Copyright © Genetic Computer School 2008

Computer Systems Architecture

Memory Management In Virtual System

Demand Paging

Fetching

Perfecting

Replacement Strategies

Page 11: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 11Copyright © Genetic Computer School 2008

Computer Systems Architecture

Memory Manager

Provides abstraction of a protected address space through translation.

Provides the abstraction of large virtual address spaces, effectively liberating programmers from physical memory constraints.

Page 12: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 12Copyright © Genetic Computer School 2008

Computer Systems Architecture

Address Translation Mechanisms_1

Efficiency in sparse address space

Address translation for protection

Generic address translation

Obvious solution

Page 13: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 13Copyright © Genetic Computer School 2008

Computer Systems Architecture

Address Translation Mechanisms_2

Paging

Protection

Problems

Advantages

Obvious solution

Page 14: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 14Copyright © Genetic Computer School 2008

Computer Systems Architecture

Memory Management ProblemsTypical Problem

Parameter free or dangling pointer

Memory leak

External fragmentation

Poor locality of reference

Inflexible design

Interface complexity

Page 15: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 15Copyright © Genetic Computer School 2008

Computer Systems Architecture

Advantages Of Memory Management

It can be easier for the programmer to

understand exactly what is going on;

Some manual memory managers perform

better when there is a shortage of

memory.

Page 16: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 16Copyright © Genetic Computer School 2008

Computer Systems Architecture

Disadvantages Of Memory ManagementThe programmer must write a lot of code to

do repetitive bookkeeping of memory;

Memory management must form a

significant part of any module interface;

Manual memory management typically

requires more memory overhead per object;

Memory management bugs are common.

Page 17: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 17Copyright © Genetic Computer School 2008

Computer Systems Architecture

Manual Memory Management In Most Implementations

Algol

C

C++

The following languages use mainly manual memory management in most implementations, although many have conservative garbage collection extensions:

COBOL

Fortran

Pascal.

Page 18: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 18Copyright © Genetic Computer School 2008

Computer Systems Architecture

Advantages Of Automatic Memory Management

The programmer is freed to work on the actual

problem

Module interfaces are cleaner

There are fewer memory management bugs

Memory management is often more efficient

Page 19: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 19Copyright © Genetic Computer School 2008

Computer Systems Architecture

Disadvantages Of Automatic Memory Management

Memory may be retained because it is

reachable, but won't be used again;

Automatic memory managers (currently)

have limited availability.

Page 20: Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management

SA 7- 20Copyright © Genetic Computer School 2008

Computer Systems Architecture

Most Modern Languages Used Mainly In

Automatic Memory ManagementBASIC

DylanTM

Erlang

Haskell

JavaTM

JavaScriptTM

Lisp

ML

Modula-3

Perl

thePostScript® language

Prolog

Python

Scheme

Smalltalk