33

37
1 Logical vs Physical address MMU, Swapping Storage Management

Transcript of 33

1

• Logical vs Physical address

• MMU, Swapping

Storage Management

2

HOME PREVIOUS TOPIC NEXTPREVIOUS QUESTION PAPERS FOR OSCPP TUTORIALS

3

Recap

In the last class, you have learnt

• Dynamic linking

-advantages and disadvantages

• Overlays

-advantages and disadvantages

4

Objectives

On completion of this class, you will be able to

know

• Logical and Physical addresses

• MMU

• Swapping

Logical Vs Physical addressLogical address• Address generated by the CPU

Physical address• Address seen by the memory unit i.e. the one

loaded into memory- address register

Compile –time and Load time address binding methods generate same logical address and physical address

4

Logical Vs Physical address

• Execution time address binding scheme results

in different logical and physical addresses

• Address generated by CPU at execution is

referred as Virtual address

• Logical address space is the set of all logical

addresses generated by program is a logical

address space

5

7

Memory Map Unit (MMU)

• MMU is a hardware device

• Maps virtual address to physical address at run

time

• A simple MMU scheme consists relocation register

• A relocation register is a base register

8

Relocation Register

Memory

Base Register

CPU Instruction

Address

+

BA

MA MA+BA

PhysicalAddress

LogicalAddress

9

Memory Map Unit (MMU)

• Address generated by the CPU are added to

relocation register as shown in previous slide

• Physical address = logical address + contents

of relocation register

• This process is called Dynamic relocation

• The user program deals with logical addresses;

– it never sees the real physical addresses

10

Memory Map Unit

• Example 1:

Logical address = 346

Relocation register = 14,000

Physical address = 346+14000

= 14346

11

Dynamic relocation ( MMU )Example 1

12

Logical address

1800MemoryCPU

14000

Relocation register

Physical address

15800

Dynamic relocation ( MMU )

MMU

+

Example 2

13

Swapping

• A process needs to be in memory to be

executed

• A process can be swapped temporarily out of

memory to a backing store

• Then brought back into memory for continued

execution as shown in next slide

14

Schematic View of Swapping

15

Swapping

Backing store

– Fast disk large enough to accommodate copies of all

memory images for all users

– Must provide direct access to these memory images

16

Swapping

• In Multiprogramming environment and round-

robin CPU scheduling

• When time quantum expires

– the memory manager will swap-out the process to

backing store

– and swap-in another process to the memory space

occupied by the swapped-out process

17

• This process continues until all the processes

are executed

• The memory manager swaps the processes

fast enough

• All ways one process is present in memory

Swapping

18

19

Priority based scheduling

• Another variant of swapping policy

• Higher priority process is swapped-in and lower

priority swapped-out

• Here the variant used is

– roll-in and roll-out

• Example for Priority based scheduling in next

slides

Swapping

20

Swapping

Monitor

Disk

UserPartition

21

Monitor

Disk

User 1

UserPartition

Swapping (contd.)

22

Monitor

User 1

Disk

User 1

UserPartition

Swapping (contd.)

23

Monitor

User 2

User 1

Disk

User 1

UserPartition

Swapping (contd.)

24

Monitor

Disk

User 2

User 2

UserPartition

User 1

Swapping (contd.)

25

Monitor

Disk

User 2

User 2

UserPartition

User 1

Swapping (contd.)

26

Monitor

Disk

User 1

User 2

UserPartition

User 1

Swapping (contd.)

27

• Major part of swap time is transfer time

• Total transfer time is directly proportional to the

amount of memory swapped

• Modified versions of swapping are found on

many systems, i.e., UNIX, Linux, and Windows

Swapping

28

Summary

In this class, you have learnt

• Logical and physical addresses

• MMU

• Swapping

29

Frequently Asked Questions

• Write the differences between logical and physical address space

• Define logical, virtual and physical addresses

• Draw and explain the basic dynamic relocation unit (MMU)

• Explain the concept of swapping

30

Quiz

1. Address seen by the memory unit

a) Logical

b) Physical

c) Virtual

d) None

31

2. Address generated by the CPU at compile

and load time

a) Logical

b) Physical

c) Virtual

d) None

Quiz

32

3. Address generated by the CPU at execution time

a) Logical

b) Physical

c) Virtual

d) None

Quiz

33

4. A relocation register is a ______register

a) Base

b) Limit

c) Offset

d) None

Quiz

34

Quiz

5. For ___________scheduling when time quantum

expires the memory manager will swap-out the

process to backing store

a) Round robin

b) Priority

c) FIFO

d) None

Other subject materials

• Web designing

• Micro processors

• C++ tutorials

• java

home

36

6. Another variant of swapping policy-

a) Priority

b) Round robin

c) FIFO

d) None

Quiz

37

7. Total transfer time is directly proportional to the

amount of memory swapped

a) True

b) False

Quiz