SlideShare a Scribd company logo
Memory
Management
Background
▪ Memory management is the functionality of an operating system which
handles or manages primary memory and moves processes back and forth
between main memory and disk during execution.
▪ The CPU fetches instructions from memory according to the value of the
program counter
▪ These instructions may cause additional loading from and storing to
specific memory addresses.
2
Basic Hardware
▪ Program must be brought (from disk) into memory and placed within a
process for it to be run.
▪ Main memory and the registers are the only storage CPU can access
directly.
▪ Registers that are built into the CPU are generally accessible within one
cycle of the CPU clock.
▪ Main memory takes many cycles.
▪ In such cases, the processor normally needs to stall, since it does not have
the data required to complete the instruction that it is executing.
▪ This is not a good situation.
▪ Solution - Cache memory 3
Basic Hardware
▪ Along with the access speed we must also consider protection of memory
▪ Protection must be provided by the hardware.
▪ Each process requires separate address space.
▪ To do this, we need the ability to determine the range of legal addresses
that the process may access and to ensure that the process can access only
these legal addresses.
▪ To provide protection two registers are used
□ base register - holds the smallest legal physical memory address
□ limit register - size of the range
4
Basic Hardware
5
For example, if the base register holds 300040 and the
limit register is 120900, then the program can legally
access all addresses from 300040 through 420939
(inclusive).
Protection
▪ CPU hardware compares every address generated in user mode with the
registers.
▪ Any attempt by a program executing in user mode to access operating-system
memory or other users' memory results in a trap to the operating system, which
treats the attempt as a fatal error.
▪ This scheme prevents a user program from (accidentally or deliberately)
modifying the code or data structures of either the operating system or other users.
▪ The base and limit registers can be loaded only by the operating system, which
uses a special privileged instruction. Since privileged instructions can be executed
only in kernel mode, and since only the operating system executes in kernel mode,
only the operating system can load the base and limit registers.
▪ This scheme allows the operating system to change the value of the registers but
prevents user programs from changing the registers' contents 6
Basic Hardware
7
Address Binding
▪ Logical address – generated by the CPU
▪ Physical address – address seen by the memory unit .
▪ Address binding is the process of mapping from one address space to
another address space.
▪ Logical and physical addresses are the same in compile time and load
time address binding schemes
▪ logical and physical addresses differ in execution time address binding
scheme
▪ An address binding can be done in three different ways:
□ Compile time
□ Load time
□ Execution time
8
Compile time:
▪ If you know at compile time where the process will reside in memory, then
absolute code can be generated.
▪ For example, if you know that a user process will reside starting at location R,
then the generated compiler code will start at that location and extend up from
there.
▪ If, at some later time, the starting location changes, then it will be necessary to
recompile this code.
▪ The MS-DOS .COM-format programs are bound at compile time.
9
Load time
▪ If it is not known at compile time where the process will reside in memory, then
the compiler must generate re-locatable code.
▪ In this case, final binding is delayed until load time.
▪ If the starting address changes, we need only reload the user code to incorporate
this changed value.
Execution time
▪ If the process can be moved during its execution from one memory segment to
another, then binding must be delayed until run time.
▪ Special hardware must be available for this scheme to work.
▪ Most general-purpose operating systems use this method.
10
Thanks!
11

More Related Content

PPT
Structure And Role Of The Processor
DOCX
Memory managment
PPSX
Understanding memory management
PDF
PPTX
Memory Management
DOCX
Memory technologies
PPT
08 Operating System Support
PPTX
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Structure And Role Of The Processor
Memory managment
Understanding memory management
Memory Management
Memory technologies
08 Operating System Support
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation

What's hot (20)

DOCX
DMA Controller Modes Of Operation
PPTX
Memory hierarchy
PPTX
Memory management
PDF
Computer organization memory
PPT
04 cache memory
PDF
Operating Systems 1 (9/12) - Memory Management Concepts
ODP
Direct Memory Access (DMA)-Working and Implementation
PPT
Memory hierarchy
PPT
Ios103 ios102 iv-operating-system-memory-management_wk4
PDF
Operating Systems - memory management
PPTX
Direct memory access
DOC
Dma transfer
PPTX
EC8791 consumer electronics-platform level performance analysis
PPTX
Direct memory access
PPTX
7 eti pres
PPT
8.replication
PPTX
Cache memory principles
PPT
Ch 4 95
PDF
Memory management OS
DMA Controller Modes Of Operation
Memory hierarchy
Memory management
Computer organization memory
04 cache memory
Operating Systems 1 (9/12) - Memory Management Concepts
Direct Memory Access (DMA)-Working and Implementation
Memory hierarchy
Ios103 ios102 iv-operating-system-memory-management_wk4
Operating Systems - memory management
Direct memory access
Dma transfer
EC8791 consumer electronics-platform level performance analysis
Direct memory access
7 eti pres
8.replication
Cache memory principles
Ch 4 95
Memory management OS
Ad

Similar to Memory management basics (20)

PDF
Memory Management Strategies - I.pdf
PPTX
Operating Systems Module 4_Memory Management.pptx
PDF
Memory Management(MM) in operating system
DOCX
Main memoryfinal
PPTX
Operating system 32 logical versus physical address
DOCX
Mainmemoryfinal 161019122029
DOCX
Mainmemoryfinalprefinal 160927115742
PPT
main memory
PDF
Main Memory - Part1
DOCX
Assembly Language
PPTX
Memory Managment(OS).pptx
PPTX
Memory Management techniques -ch8_1.pptx
PPT
Chapter 8 memory-updated
PDF
Section08 memory management
PPTX
Operating System_2.1_Memory Management.pptx
PPT
Main memory os - prashant odhavani- 160920107003
PPT
Memory management principles in operating systems
PPTX
HW29kkkkkkkkkkkkkkkkkkkmmmmkkmmkkk454.pptx
PPT
operationg systemsdocumentmemorymanagement
PPT
OS-unit-3 part -1mxmxmxmmxmxmmxmxmxmxmxmmxmxmmx.ppt
Memory Management Strategies - I.pdf
Operating Systems Module 4_Memory Management.pptx
Memory Management(MM) in operating system
Main memoryfinal
Operating system 32 logical versus physical address
Mainmemoryfinal 161019122029
Mainmemoryfinalprefinal 160927115742
main memory
Main Memory - Part1
Assembly Language
Memory Managment(OS).pptx
Memory Management techniques -ch8_1.pptx
Chapter 8 memory-updated
Section08 memory management
Operating System_2.1_Memory Management.pptx
Main memory os - prashant odhavani- 160920107003
Memory management principles in operating systems
HW29kkkkkkkkkkkkkkkkkkkmmmmkkmmkkk454.pptx
operationg systemsdocumentmemorymanagement
OS-unit-3 part -1mxmxmxmmxmxmmxmxmxmxmxmmxmxmmx.ppt
Ad

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
RMMM.pdf make it easy to upload and study
PPTX
master seminar digital applications in india
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Pharma ospi slides which help in ospi learning
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Presentation on HIE in infants and its manifestations
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Institutional Correction lecture only . . .
Cell Types and Its function , kingdom of life
RMMM.pdf make it easy to upload and study
master seminar digital applications in india
Microbial disease of the cardiovascular and lymphatic systems
human mycosis Human fungal infections are called human mycosis..pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
01-Introduction-to-Information-Management.pdf
Final Presentation General Medicine 03-08-2024.pptx
Final Presentation General Medicine 03-08-2024.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Pharma ospi slides which help in ospi learning
102 student loan defaulters named and shamed – Is someone you know on the list?
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Presentation on HIE in infants and its manifestations
STATICS OF THE RIGID BODIES Hibbelers.pdf
Institutional Correction lecture only . . .

Memory management basics

  • 2. Background ▪ Memory management is the functionality of an operating system which handles or manages primary memory and moves processes back and forth between main memory and disk during execution. ▪ The CPU fetches instructions from memory according to the value of the program counter ▪ These instructions may cause additional loading from and storing to specific memory addresses. 2
  • 3. Basic Hardware ▪ Program must be brought (from disk) into memory and placed within a process for it to be run. ▪ Main memory and the registers are the only storage CPU can access directly. ▪ Registers that are built into the CPU are generally accessible within one cycle of the CPU clock. ▪ Main memory takes many cycles. ▪ In such cases, the processor normally needs to stall, since it does not have the data required to complete the instruction that it is executing. ▪ This is not a good situation. ▪ Solution - Cache memory 3
  • 4. Basic Hardware ▪ Along with the access speed we must also consider protection of memory ▪ Protection must be provided by the hardware. ▪ Each process requires separate address space. ▪ To do this, we need the ability to determine the range of legal addresses that the process may access and to ensure that the process can access only these legal addresses. ▪ To provide protection two registers are used □ base register - holds the smallest legal physical memory address □ limit register - size of the range 4
  • 5. Basic Hardware 5 For example, if the base register holds 300040 and the limit register is 120900, then the program can legally access all addresses from 300040 through 420939 (inclusive).
  • 6. Protection ▪ CPU hardware compares every address generated in user mode with the registers. ▪ Any attempt by a program executing in user mode to access operating-system memory or other users' memory results in a trap to the operating system, which treats the attempt as a fatal error. ▪ This scheme prevents a user program from (accidentally or deliberately) modifying the code or data structures of either the operating system or other users. ▪ The base and limit registers can be loaded only by the operating system, which uses a special privileged instruction. Since privileged instructions can be executed only in kernel mode, and since only the operating system executes in kernel mode, only the operating system can load the base and limit registers. ▪ This scheme allows the operating system to change the value of the registers but prevents user programs from changing the registers' contents 6
  • 8. Address Binding ▪ Logical address – generated by the CPU ▪ Physical address – address seen by the memory unit . ▪ Address binding is the process of mapping from one address space to another address space. ▪ Logical and physical addresses are the same in compile time and load time address binding schemes ▪ logical and physical addresses differ in execution time address binding scheme ▪ An address binding can be done in three different ways: □ Compile time □ Load time □ Execution time 8
  • 9. Compile time: ▪ If you know at compile time where the process will reside in memory, then absolute code can be generated. ▪ For example, if you know that a user process will reside starting at location R, then the generated compiler code will start at that location and extend up from there. ▪ If, at some later time, the starting location changes, then it will be necessary to recompile this code. ▪ The MS-DOS .COM-format programs are bound at compile time. 9
  • 10. Load time ▪ If it is not known at compile time where the process will reside in memory, then the compiler must generate re-locatable code. ▪ In this case, final binding is delayed until load time. ▪ If the starting address changes, we need only reload the user code to incorporate this changed value. Execution time ▪ If the process can be moved during its execution from one memory segment to another, then binding must be delayed until run time. ▪ Special hardware must be available for this scheme to work. ▪ Most general-purpose operating systems use this method. 10