Docsity

Memory Management in Operating Systems: Static and Dynamic Relocation, Lecture notes of Operating Systems

Toggle sidebar
bg1
UNIVERSITY of WISCONSIN-MADISON
Computer Sciences Department
CS 537 A. Arpaci-Dusseau
Intro to Operating Systems Spring 2000
Questions answered in these notes
•How do processes share main memory?
•What are the advantages and disadvantages of static relocation?
•What are the advantages and disadvantages of dynamic relocation?
•How does the memory management interact with hardware?
Readings for this lecture
Silberschatz/Galvin: Chapter 8
Memory Management
A.Arpaci-DusseauCS 537:Operating Systems Lecture13.fm.2
Motivation
Simple uniprogramming with a single segment per process
Early batch monitors
Personal computers
Disadvantages
•Only one process can run at a time
•Process can destroy OS
0
2^N
OS
User
Process
Highest memory holds OS
Process starts at memory address 0, up to the OS
A.Arpaci-DusseauCS 537:Operating Systems Lecture13.fm.3
Goals for Multiprogramming
Sharing
•Several processes to coexist in main memory
Transparency
•Processes not aware that memory is shared
•Run regardless of number and/or locations of processes
Protection
•Cannot corrupt OS or other processes
•Privacy: Cannot read data of other processes
Efficiency should not be severely degraded
•Purpose of sharing is to increase efficiency
•Do not waste CPU or memory resources
A.Arpaci-DusseauCS 537:Operating Systems Lecture13.fm.4
Static Relocation
Transparency --> Relocation
•Processes can run anywhere in memory (can’t predict in advance)
•Modify addresses statically (similar to linker) when load process
Advantages
•Allows multiple processes to run
•Requires no hardware support
0
2^N
OS
Process 1
Process 2
Process 3
Highest memory holds OS
Processes allocated starting at 0, up to the OS
pf3

Partial preview of the text

Download Memory Management in Operating Systems: Static and Dynamic Relocation and more Lecture notes Operating Systems in PDF only on Docsity!

UNIVERSITY of WISCONSIN-MADISON

Computer Sciences Department

CS 537

A. Arpaci-Dusseau

Intro to Operating Systems

Spring 2000

Questions answered in these notes

-

How do processes share main memory?

-

What are the advantages and disadvantages of static relocation?

-

What are the advantages and disadvantages of dynamic relocation?

-

How does the memory management interact with hardware?

Readings for this lecture

Silberschatz/Galvin: Chapter 8

Memory Management

A.Arpaci-Dusseau

CS 537:Operating Systems

Lecture13.fm.

Motivation

Simple uniprogramming with a single segment per process

Early batch monitorsPersonal computers

Disadvantages

-

Only one process can run at a time

-

Process can destroy OS

0 2^N

OS User Process

Highest memory holds OSProcess starts at memory address 0, up to the OS

A.Arpaci-Dusseau

CS 537:Operating Systems

Lecture13.fm.

Goals for Multiprogramming

Sharing

-

Several processes to coexist in main memory

Transparency

-

Processes not aware that memory is shared

-

Run regardless of number and/or locations of processes

Protection

-

Cannot corrupt OS or other processes

-

Privacy: Cannot read data of other processes

Efficiency should not be severely degraded

-

Purpose of sharing is to increase efficiency

-

Do not waste CPU or memory resources

A.Arpaci-Dusseau

CS 537:Operating Systems

Lecture13.fm.

Static Relocation

Transparency --> Relocation

-

Processes can run anywhere in memory (can’t predict in advance)

-

Modify addresses statically (similar to linker) when

load

process

Advantages

-

Allows multiple processes to run

-

Requires no hardware support

2^N 0

OS

Process 2Process 1

Process 3

Highest memory holds OSProcesses allocated starting at 0, up to the OS

A.Arpaci-Dusseau

CS 537:Operating Systems

Lecture13.fm.

Disadvantages of Static Relocation

Process allocation must be contiguous

-

Fragmentation: May not be able to allocate new process

What kind?

-

Processes may not be able to increase address space

-

Can’t move process after it has been placed?

No protection: Destroy other processes and/or the OS

2^N 0

OS

Process 2Process 1 Process 3

A.Arpaci-Dusseau

CS 537:Operating Systems

Lecture13.fm.

Dynamic Relocation

Change address dynamically at every referenceProgram-generated address translated to hardware address

-

Program addresses are called

logical or virtual

addresses

-

Hardware addresses are called

physical or real

addresses.

Address space: View of memory for each process

CPU

MMU

Memory

Logical Addresses

Physical Addresses

Memory Management Unit

OS controls MMU

A.Arpaci-Dusseau

CS 537:Operating Systems

Lecture13.fm.

Address Spaces

Translation from logical to physical addresses

N 0

Memory

Address Space 1 Address Space 2Address Space 3

Logical view

Physical view

0 0 0

OS

1 process, multiple threads

stackheapcode

A.Arpaci-Dusseau

CS 537:Operating Systems

Lecture13.fm.

Hardware Support

Two operating modes

-

Privileged (protected, kernel) mode

: When OS runs

When trap into OS (system calls, interrupts, errors)Allows certain instructions to be executedAllows OS to access all of physical memory

-

User mode:

When user processes run

Performs translation of logical address to physical address

Base and Bounds registers for translation

-

Base register:

Start location for address space

-

Bounds register:

Last valid address the process may generate

Appears to have private memory of size equal to bounds register