SlideShare a Scribd company logo
CSE323 Memory Management 1
CSE323 Memory ManagementCSE323 Memory Management
Textbook Ch9Textbook Ch9
These slides were compiled from the OSC textbook slides (Silberschatz, Galvin,
and Gagne) and the instructor’s class materials.
Base and Limit Registers
 A pair of base and limit registers define the logical address space
 CPU must check every memory access generated in user mode to be sure it is between base
and limit for that user
Hardware Address Protection with Base and Limit Registers
Address Binding
 Programs on disk, ready to be brought into memory to execute form an input
queue
 Inconvenient to have first user process physical address always at 0000
 Addresses represented in different ways at different stages of a program’s life
 Source code addresses are usually symbolic
 A Compiler bind this symbolic address to relocatable addresses

i.e. “14 bytes from beginning of this module”
 Linker or loader will bind relocatable addresses to absolute addresses

i.e. 74014
 Each binding maps one address space to another
CSE323 Memory Management 5
Binding of Instructions and Data to
Memory Addresses
Compile time: If memory location known a priori, absolute code can be
generated; must recompile code if starting location changes.
Load time: If memory location is not known at compile time, compiler
must generate relocatable code.
Loader knows final location and binds addresses for that location
Execution time: If the process can be moved during its execution,
binding must be delayed until run time. Need hardware support for
address maps (e.g., base and limit registers).
Memory-Management Unit (MMU)
 MMU is the Hardware device that maps virtual address to physical address at
run time
 To start, consider simple scheme where the value in the relocation register is
added to every address generated by a user process at the time it is sent to
memory
 Base register now called relocation register
 MS-DOS on Intel 80x86 used 4 relocation registers
 The user program deals with logical addresses; it never sees the real physical
addresses
 Execution-time binding occurs when reference is made to location in
memory
CSE323 Memory Management 7
Logical vs. Physical Address
Space
 Physical address: The actual
hardware memory address.
 32-bit CPU’s physical
address 0 ~ 232
-1
(00000000 – FFFFFFFF)
 128MB’s memory
address 0 ~ 227
-1
(00000000 – 07FFFFFF)
 Logical address: Each
(relocatable) program
assumes the starting location
is always 0 and the memory
space is much larger than
actual memory
Dynamic relocation using a
relocation register
CSE323 Memory Management 8
Memory Protection
 For each process
 Logical space is mapped to a contiguous portion of physical space
 A relocation and a limit register are prepared

Relocation register = the value of the smallest physical address

Limit register = the range of logical address space
CSE323 Memory Management 9
Memory Protection
 When the CPU scheduler selects a process for
execution, the dispatcher loads the relocation and
limit registers with the correct values as part of the
context switch.
 Every address generated by the CPU is checked
against these registers.
CSE323 Memory Management 10
Dynamic Loading
 Unused routine is never
loaded
 Useful when the code
size is large
 Unix execv can be
categorized:
 Overloading a necessary
program onto the current
program.
main( ) {
f1( );
}
f1( ) {
f2( );
}
f2( ) {
f3( );
}
memory
1. Loaded when called
2. Loaded when called
3. Loaded when called
CSE323 Memory Management 11
Dynamic Linking
 Linking postponed until
execution time.
 Small piece of code,
stub, used to locate the
appropriate memory-
resident library routine.
 Stub replaces itself with
the address of the
routine, and executes
the routine.
 Operating system needs
to check if routine is in
processes’ memory
address
int x;
void main(){
stub = dlopen(“lib”):
f = dlsym(stub, “f1”);
f( );
}
extern int x;
f1( ) {
x = 5;
}
lib.so.a
memory
int x;
void main(){
stub = dlopen(“lib”):
f = dlsym(stub, “f1”);
f( );
}
extern int x;
f1( ) {
x = 5;
}
CSE323 Memory Management 12
Overlays
 Code and data used at
any given time are
placed in memory.
 New code is overloaded
onto the code not used
any more.
 It is not so frequently
used now.
CSE323 Memory Management 13
Swapping
 When a process p1 is
blocked so long (for
I/O), it is swapped out
to the backing store,
(swap area in Unix.)
 When a process p2 is
(served by I/O and )
back to a ready
queue, it is swapped
in the memory.
 Use the Unix top
command to see
which processes are
swapped out.
CSE323 Memory Management 14
Contiguous Memory Allocation
 The main memory is usually divided into two parts :
one for the operating system and one for the user
processes.
 Where the OS will reside will decide upon the location
of interrupt vector.
CSE323 Memory Management 15
Memory Allocation
(Fixed sized partition)
 Memory is divided to fixed-
sized partitions
 Each partition is allocated to a
process
 IBM OS/360
 Then, how about this
process?
OS
process1
process2
process3
process4
?
CSE323 Memory Management 16
Variable-Sized Partitions
 Primarily used in Batch environment
 The OS keeps a table indicating which parts of
memory are available and which are occupied
 Initially all memory is available for the user processes
and is considered as one large block of available
memory, “HOLE”.
 When a process arrives and needs memory, we
search for a hole large enough for this process.
 If we find one, we allocate only as much memory as
is needed.
CSE323 Memory Management 17
Variable-Sized Partitions
 Whenever one of running processes, (p8) is terminated
 Find a ready process whose size is best fit to the hole, (p9)
 Allocate it from the top of hole
 If there is still an available hole, repeat the above (for p10).
 Any size of processes, (up to the physical memory size) can be
allocated.
OS
process 5
process 8
process 2
OS
process 5
process 2
OS
process 5
process 2
OS
process 5
process 9
process 2
process 9
process 10
CSE323 Memory Management 18
Dynamic Storage-Allocation
Problem
 First-fit: Allocate the first hole that is big enough. (Fastest
search)
 Best-fit: Allocate the smallest hole that is big enough; must
search entire list, unless ordered by size. Produces the
smallest leftover hole. (Best memory usage)
 Worst-fit: Allocate the largest hole; must also search entire
list. Produces the largest leftover hole (that could be used
effectively later.)
First-fit and best-fit better than worst-fit in terms of
speed and storage utilization.
CSE323 Memory Management 19
External Fragmentation
 Problem
 50-percent rule (for first fit):
total memory space exists
to satisfy a request, but it is
not contiguous.
 Solution
 Compaction: shuffle the
memory contents to place
all free memory together in
one large block

Relocatable code

Expensive
 Paging: Allow non-
contiguous logical-to-
phyiscal space mapping.
process1
process2
process3
Can’t fit
Shift up
CSE323 Memory Management 20
Internal Fragmentation
 With the scheme of breaking the physical memory
into fixed-sized blocks, and allocate memory in unit of
block size, results internal fragmentation.
 With this approach, the memory allocated to a
process may be slightly larger than the requested
memory. The difference between these two number
is internal fragmentation.
Segmentation
 Memory-management scheme that supports user view of
memory
 A program is a collection of segments
 A segment is a logical unit such as:
main program
procedure
function
method
object
local variables, global variables
common block
stack
symbol table
arrays
User’s View of a Program
Logical View of Segmentation
Data
Code
Stack
Heap
user view of memory
Data
Heap
Stack
Code
logical memory space
Segmentation Architecture
 Logical address consists of a two tuple:
<segment-number, offset>,
 Segment table – maps two-dimensional physical addresses; each table entry
has:
 base – contains the starting physical address where the segments reside
in memory
 limit – specifies the length of the segment
 Segment-table base register (STBR) points to the segment table’s
location in memory
 Segment-table length register (STLR) indicates number of segments
used by a program;
segment number s is legal if s < STLR
Segmentation Architecture
(Cont.)
 Protection
 With each entry in segment table associate:

validation bit = 0 ⇒ illegal segment

read/write/execute privileges
 Protection bits associated with segments; code sharing occurs
at segment level
 Since segments vary in length, memory allocation is a dynamic
storage-allocation problem
 A segmentation example is shown in the following diagram
Segmentation Hardware
CSE323 Memory Management 27
Segmentation Example
used
PC
used
SP
Stack top
Currently executed
offset d1 d1
offset d2
d2
CSE323 Memory Management 28

More Related Content

What's hot

Deterministic Memory Abstraction and Supporting Multicore System Architecture
Deterministic Memory Abstraction and Supporting Multicore System ArchitectureDeterministic Memory Abstraction and Supporting Multicore System Architecture
Deterministic Memory Abstraction and Supporting Multicore System Architecture
Heechul Yun
 
Memory management
Memory managementMemory management
Memory management
cpjcollege
 
Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742
marangburu42
 
ppt
pptppt
Main memory os - prashant odhavani- 160920107003
Main memory   os - prashant odhavani- 160920107003Main memory   os - prashant odhavani- 160920107003
Main memory os - prashant odhavani- 160920107003
Prashant odhavani
 
Memory Management
Memory ManagementMemory Management
Memory Management
Shipra Swati
 
Memory management
Memory managementMemory management
Memory management
Muhammad Fayyaz
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OSC.U
 
Operation System
Operation SystemOperation System
Operation System
ANANTHI1997
 
Process management
Process managementProcess management
Process managementMohd Arif
 
Operating System
Operating SystemOperating System
Operating System
Subhasis Dash
 
previous question solve of operating system.
previous question solve of operating system.previous question solve of operating system.
previous question solve of operating system.
Ibrahim Khalil Shakik
 
34 single partition allocation
34 single partition allocation34 single partition allocation
34 single partition allocationmyrajendra
 
Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029
marangburu42
 
Main memoryfinal
Main memoryfinalMain memoryfinal
Main memoryfinal
marangburu42
 

What's hot (20)

Deterministic Memory Abstraction and Supporting Multicore System Architecture
Deterministic Memory Abstraction and Supporting Multicore System ArchitectureDeterministic Memory Abstraction and Supporting Multicore System Architecture
Deterministic Memory Abstraction and Supporting Multicore System Architecture
 
Memory management
Memory managementMemory management
Memory management
 
Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742
 
ppt
pptppt
ppt
 
Main memory os - prashant odhavani- 160920107003
Main memory   os - prashant odhavani- 160920107003Main memory   os - prashant odhavani- 160920107003
Main memory os - prashant odhavani- 160920107003
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
Main Memory
Main MemoryMain Memory
Main Memory
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Memory management
Memory managementMemory management
Memory management
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
Operation System
Operation SystemOperation System
Operation System
 
Process management
Process managementProcess management
Process management
 
Cache
CacheCache
Cache
 
Operating System
Operating SystemOperating System
Operating System
 
previous question solve of operating system.
previous question solve of operating system.previous question solve of operating system.
previous question solve of operating system.
 
34 single partition allocation
34 single partition allocation34 single partition allocation
34 single partition allocation
 
Cachememory
CachememoryCachememory
Cachememory
 
Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029
 
Main memoryfinal
Main memoryfinalMain memoryfinal
Main memoryfinal
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 

Similar to Chapter 8 memory-updated

Memory management OS
Memory management OSMemory management OS
Memory management OS
UmeshchandraYadav5
 
Memory Managment(OS).pptx
Memory Managment(OS).pptxMemory Managment(OS).pptx
Memory Managment(OS).pptx
RohitPaul71
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
Kadu37
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
ssuser143a20
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3
Kathirvel Ayyaswamy
 
CH08.pdf
CH08.pdfCH08.pdf
CH08.pdf
ImranKhan880955
 
Memory Management
Memory ManagementMemory Management
Memory Management
sangrampatil81
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
Ajit Nayak
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
SourabhRaj29
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
Johan Granados Montero
 
ECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docxECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docx
tidwellveronique
 
ECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docxECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docx
tidwellveronique
 
ECECS 472572 Final Exam ProjectRemember to check the errata
ECECS 472572 Final Exam ProjectRemember to check the errata ECECS 472572 Final Exam ProjectRemember to check the errata
ECECS 472572 Final Exam ProjectRemember to check the errata
EvonCanales257
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
Rashmi Bhat
 
Linux memorymanagement
Linux memorymanagementLinux memorymanagement
Linux memorymanagement
pradeepelinux
 

Similar to Chapter 8 memory-updated (20)

Ch8
Ch8Ch8
Ch8
 
Memory management OS
Memory management OSMemory management OS
Memory management OS
 
Memory Managment(OS).pptx
Memory Managment(OS).pptxMemory Managment(OS).pptx
Memory Managment(OS).pptx
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3CS6401 OPERATING SYSTEMS Unit 3
CS6401 OPERATING SYSTEMS Unit 3
 
CH08.pdf
CH08.pdfCH08.pdf
CH08.pdf
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
 
OSCh9
OSCh9OSCh9
OSCh9
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
 
Memory management
Memory managementMemory management
Memory management
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
ECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docxECECS 472572 Final Exam ProjectRemember to check the errat.docx
ECECS 472572 Final Exam ProjectRemember to check the errat.docx
 
ECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docxECECS 472572 Final Exam ProjectRemember to check the err.docx
ECECS 472572 Final Exam ProjectRemember to check the err.docx
 
ECECS 472572 Final Exam ProjectRemember to check the errata
ECECS 472572 Final Exam ProjectRemember to check the errata ECECS 472572 Final Exam ProjectRemember to check the errata
ECECS 472572 Final Exam ProjectRemember to check the errata
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Linux memorymanagement
Linux memorymanagementLinux memorymanagement
Linux memorymanagement
 

More from Delowar hossain

Software model
Software modelSoftware model
Software model
Delowar hossain
 
Cse 333-assignment-software engineering
Cse 333-assignment-software engineeringCse 333-assignment-software engineering
Cse 333-assignment-software engineering
Delowar hossain
 
Assignment
AssignmentAssignment
Assignment
Delowar hossain
 
6. ch 5-understanding requirements
6. ch 5-understanding requirements6. ch 5-understanding requirements
6. ch 5-understanding requirements
Delowar hossain
 
5. ch 4-principles that guide practice
5. ch 4-principles that guide practice5. ch 4-principles that guide practice
5. ch 4-principles that guide practice
Delowar hossain
 
4. ch 3-agile process
4. ch 3-agile process4. ch 3-agile process
4. ch 3-agile process
Delowar hossain
 
3. ch 2-process model
3. ch 2-process model3. ch 2-process model
3. ch 2-process model
Delowar hossain
 
1. ch 1-introduction
1. ch 1-introduction1. ch 1-introduction
1. ch 1-introduction
Delowar hossain
 

More from Delowar hossain (8)

Software model
Software modelSoftware model
Software model
 
Cse 333-assignment-software engineering
Cse 333-assignment-software engineeringCse 333-assignment-software engineering
Cse 333-assignment-software engineering
 
Assignment
AssignmentAssignment
Assignment
 
6. ch 5-understanding requirements
6. ch 5-understanding requirements6. ch 5-understanding requirements
6. ch 5-understanding requirements
 
5. ch 4-principles that guide practice
5. ch 4-principles that guide practice5. ch 4-principles that guide practice
5. ch 4-principles that guide practice
 
4. ch 3-agile process
4. ch 3-agile process4. ch 3-agile process
4. ch 3-agile process
 
3. ch 2-process model
3. ch 2-process model3. ch 2-process model
3. ch 2-process model
 
1. ch 1-introduction
1. ch 1-introduction1. ch 1-introduction
1. ch 1-introduction
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 

Chapter 8 memory-updated

  • 1. CSE323 Memory Management 1 CSE323 Memory ManagementCSE323 Memory Management Textbook Ch9Textbook Ch9 These slides were compiled from the OSC textbook slides (Silberschatz, Galvin, and Gagne) and the instructor’s class materials.
  • 2. Base and Limit Registers  A pair of base and limit registers define the logical address space  CPU must check every memory access generated in user mode to be sure it is between base and limit for that user
  • 3. Hardware Address Protection with Base and Limit Registers
  • 4. Address Binding  Programs on disk, ready to be brought into memory to execute form an input queue  Inconvenient to have first user process physical address always at 0000  Addresses represented in different ways at different stages of a program’s life  Source code addresses are usually symbolic  A Compiler bind this symbolic address to relocatable addresses  i.e. “14 bytes from beginning of this module”  Linker or loader will bind relocatable addresses to absolute addresses  i.e. 74014  Each binding maps one address space to another
  • 5. CSE323 Memory Management 5 Binding of Instructions and Data to Memory Addresses Compile time: If memory location known a priori, absolute code can be generated; must recompile code if starting location changes. Load time: If memory location is not known at compile time, compiler must generate relocatable code. Loader knows final location and binds addresses for that location Execution time: If the process can be moved during its execution, binding must be delayed until run time. Need hardware support for address maps (e.g., base and limit registers).
  • 6. Memory-Management Unit (MMU)  MMU is the Hardware device that maps virtual address to physical address at run time  To start, consider simple scheme where the value in the relocation register is added to every address generated by a user process at the time it is sent to memory  Base register now called relocation register  MS-DOS on Intel 80x86 used 4 relocation registers  The user program deals with logical addresses; it never sees the real physical addresses  Execution-time binding occurs when reference is made to location in memory
  • 7. CSE323 Memory Management 7 Logical vs. Physical Address Space  Physical address: The actual hardware memory address.  32-bit CPU’s physical address 0 ~ 232 -1 (00000000 – FFFFFFFF)  128MB’s memory address 0 ~ 227 -1 (00000000 – 07FFFFFF)  Logical address: Each (relocatable) program assumes the starting location is always 0 and the memory space is much larger than actual memory Dynamic relocation using a relocation register
  • 8. CSE323 Memory Management 8 Memory Protection  For each process  Logical space is mapped to a contiguous portion of physical space  A relocation and a limit register are prepared  Relocation register = the value of the smallest physical address  Limit register = the range of logical address space
  • 9. CSE323 Memory Management 9 Memory Protection  When the CPU scheduler selects a process for execution, the dispatcher loads the relocation and limit registers with the correct values as part of the context switch.  Every address generated by the CPU is checked against these registers.
  • 10. CSE323 Memory Management 10 Dynamic Loading  Unused routine is never loaded  Useful when the code size is large  Unix execv can be categorized:  Overloading a necessary program onto the current program. main( ) { f1( ); } f1( ) { f2( ); } f2( ) { f3( ); } memory 1. Loaded when called 2. Loaded when called 3. Loaded when called
  • 11. CSE323 Memory Management 11 Dynamic Linking  Linking postponed until execution time.  Small piece of code, stub, used to locate the appropriate memory- resident library routine.  Stub replaces itself with the address of the routine, and executes the routine.  Operating system needs to check if routine is in processes’ memory address int x; void main(){ stub = dlopen(“lib”): f = dlsym(stub, “f1”); f( ); } extern int x; f1( ) { x = 5; } lib.so.a memory int x; void main(){ stub = dlopen(“lib”): f = dlsym(stub, “f1”); f( ); } extern int x; f1( ) { x = 5; }
  • 12. CSE323 Memory Management 12 Overlays  Code and data used at any given time are placed in memory.  New code is overloaded onto the code not used any more.  It is not so frequently used now.
  • 13. CSE323 Memory Management 13 Swapping  When a process p1 is blocked so long (for I/O), it is swapped out to the backing store, (swap area in Unix.)  When a process p2 is (served by I/O and ) back to a ready queue, it is swapped in the memory.  Use the Unix top command to see which processes are swapped out.
  • 14. CSE323 Memory Management 14 Contiguous Memory Allocation  The main memory is usually divided into two parts : one for the operating system and one for the user processes.  Where the OS will reside will decide upon the location of interrupt vector.
  • 15. CSE323 Memory Management 15 Memory Allocation (Fixed sized partition)  Memory is divided to fixed- sized partitions  Each partition is allocated to a process  IBM OS/360  Then, how about this process? OS process1 process2 process3 process4 ?
  • 16. CSE323 Memory Management 16 Variable-Sized Partitions  Primarily used in Batch environment  The OS keeps a table indicating which parts of memory are available and which are occupied  Initially all memory is available for the user processes and is considered as one large block of available memory, “HOLE”.  When a process arrives and needs memory, we search for a hole large enough for this process.  If we find one, we allocate only as much memory as is needed.
  • 17. CSE323 Memory Management 17 Variable-Sized Partitions  Whenever one of running processes, (p8) is terminated  Find a ready process whose size is best fit to the hole, (p9)  Allocate it from the top of hole  If there is still an available hole, repeat the above (for p10).  Any size of processes, (up to the physical memory size) can be allocated. OS process 5 process 8 process 2 OS process 5 process 2 OS process 5 process 2 OS process 5 process 9 process 2 process 9 process 10
  • 18. CSE323 Memory Management 18 Dynamic Storage-Allocation Problem  First-fit: Allocate the first hole that is big enough. (Fastest search)  Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. (Best memory usage)  Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole (that could be used effectively later.) First-fit and best-fit better than worst-fit in terms of speed and storage utilization.
  • 19. CSE323 Memory Management 19 External Fragmentation  Problem  50-percent rule (for first fit): total memory space exists to satisfy a request, but it is not contiguous.  Solution  Compaction: shuffle the memory contents to place all free memory together in one large block  Relocatable code  Expensive  Paging: Allow non- contiguous logical-to- phyiscal space mapping. process1 process2 process3 Can’t fit Shift up
  • 20. CSE323 Memory Management 20 Internal Fragmentation  With the scheme of breaking the physical memory into fixed-sized blocks, and allocate memory in unit of block size, results internal fragmentation.  With this approach, the memory allocated to a process may be slightly larger than the requested memory. The difference between these two number is internal fragmentation.
  • 21. Segmentation  Memory-management scheme that supports user view of memory  A program is a collection of segments  A segment is a logical unit such as: main program procedure function method object local variables, global variables common block stack symbol table arrays
  • 22. User’s View of a Program
  • 23. Logical View of Segmentation Data Code Stack Heap user view of memory Data Heap Stack Code logical memory space
  • 24. Segmentation Architecture  Logical address consists of a two tuple: <segment-number, offset>,  Segment table – maps two-dimensional physical addresses; each table entry has:  base – contains the starting physical address where the segments reside in memory  limit – specifies the length of the segment  Segment-table base register (STBR) points to the segment table’s location in memory  Segment-table length register (STLR) indicates number of segments used by a program; segment number s is legal if s < STLR
  • 25. Segmentation Architecture (Cont.)  Protection  With each entry in segment table associate:  validation bit = 0 ⇒ illegal segment  read/write/execute privileges  Protection bits associated with segments; code sharing occurs at segment level  Since segments vary in length, memory allocation is a dynamic storage-allocation problem  A segmentation example is shown in the following diagram
  • 27. CSE323 Memory Management 27 Segmentation Example used PC used SP Stack top Currently executed offset d1 d1 offset d2 d2

Editor's Notes

  1. Hello! Everyone, My name is Shinya Kobayashi. Today, I am going to present our paper titled “Inter-Cluster Job Coordination Using Mobile Agents” on behalf of the first author, Munehiro Fukuda. Munehiro was hoping to show up and present the paper at AMS2001, however he got to wait in Japan until he will get an H1B visa. Since I received the presentation materials from him quite recently, please allow me to present this paper using this script. I can respond to your questions as far as I know, however you can also ask Munehiro by email. His email address is on the title page of our paper. (time 1:05)