2. HOME PREVIOUS TOPIC NEXT
PREVIOUS QUESTION PAPERS FOR OS
CPP TUTORIALS
2
3. Recap
In the last class, you have learnt
• Dynamic linking
- advantages and disadvantages
• Overlays
advantages and disadvantages
-
3
4. Objectives
On completion of this class, you will be able to
know
• Logical and Physical addresses
• MMU
• Swapping
4
5. Logical Vs Physical address
Logical 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
6. 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
7
8. Relocation Register
Base Register
BA
Logical Physical
CPU Address Address
Instruction + Memory
MA MA+BA
Address
8
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
9
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
13
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
15
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
16
17. Swapping
• 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
17
19. Swapping
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
19
23. Swapping (contd.)
Disk
Monitor
User
Partition
User 1
User 1
User 2
23
24. Swapping (contd.)
Disk
Monitor
User
Partition
User 1
User 2
User 2
24
25. Swapping (contd.)
Disk
Monitor
User
Partition
User 1
User 2
User 2
25
26. Swapping (contd.)
Disk
Monitor
User
Partition
User 1
User 1
User 2
26
27. Swapping
• 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
27
28. Summary
In this class, you have learnt
• Logical and physical addresses
• MMU
• Swapping
28
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
29
30. Quiz
1. Address seen by the memory unit
a) Logical
b) Physical
c) Virtual
d) None
30
31. Quiz
2. Address generated by the CPU at compile
and load time
a) Logical
b) Physical
c) Virtual
d) None
31
33. Quiz
4. A relocation register is a ______register
a) Base
b) Limit
c) Offset
d) None
33
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
34