SlideShare a Scribd company logo
1 of 6
Download to read offline
8
Paging and Segmentation
Prepared By: Ghayour Abbas
External fragmentation occurs because we allocate memory continuously to
the processes. Due to this space is left and memory remains unused hence, cause
external fragmentation. So to tackle this problem the concept of paging was
introduced where we divide the process into small pages and these pages are
allocated memory non-contiguously into the RAM.
Non-Contiguous Memory Allocation Technique
In the non-contiguous memory allocation technique, different parts of the
same process are stored in different places of the main memory. Types:
• Paging
• Segmentation
Paging
Paging is a non-contiguous memory allocation technique in which secondary
memory and the main memory is divided into equal size partitions. The partitions
of the secondary memory are called pages while the partitions of the main
memory are called frames. They are divided into equal size partitions to have
maximum utilization of the main memory and avoid external fragmentation.
Translation of logical Address into physical Address
As a CPU always generates a logical address and we need a physical address
for accessing the main memory.
This mapping is done by the MMU(memory management Unit) with the
help of the page table. Lets first understand some of the basic terms then we will
see how this translation is done.
Logical Address: The logical address consists of two parts page number and page
offset.
1. Page Number: It tells the exact page of the process which the CPU wants to
access.
2. Page Offset: It tells the exact word on that page which the CPU wants to
read.
Logical Address = Page Number + Page Offset
Physical Address: The physical address consists of two parts frame number and
page offset.
1. Frame Number: It tells the exact frame where the page is stored in physical
memory.
2. Page Offset: It tells the exact word on that page which the CPU wants to
read. It requires no translation as the page size is the same as the frame size
so the place of the word which CPU wants access will not change.
Physical Address = Frame Number + Page Offset
Page table: A page stable contains the frame number corresponding to the page
number of some specific process. So, each process will have its own page table. A
register called Page Table Base Register(PTBR) which holds the base value of the
page table.
Now, let's see how the translation is done.
How is the translation done?
The CPU generates the logical address which contains the page number and
the page offset. The PTBR register contains the address of the page table. Now, the
page table helps in determining the frame number corresponding to the page
number. Now, with the help of frame number and the page offset the physical
address is determined and the page is accessed in the main memory.
Advantages of Paging
• There is no external fragmentation as it allows us to store the data in a non-
contiguous way.
• Swapping is easy between equal-sized pages and frames.
Disadvantages of Paging
• As the size of the frame is fixed, so it may suffer from internal fragmentation.
It may happen that the process is too small and it may not acquire the entire
frame size.
• The access time increases because of paging as the main memory has to be
now accessed two times. First, we need to access the page table which is also
stored in the main memory and second, combine the frame number with the
page offset and then get the physical address of the page which is again
stored in the main memory.
• For every process, we have an independent page table and maintaining the
page table is extra overhead.
Segmentation
In paging, we were blindly diving the process into pages of fixed sizes but in
segmentation, we divide the process into modules for better visualization of the
process.
Here each segment or module consists of the same type of functions. For
example, the main function is included in one segment, library function is kept in
other segments, and so on. As the size of segments may vary, so memory is divided
into variable size parts.
Translation of logical Address into physical Address
As a CPU always generates a logical address and we need a physical address
for accessing the main memory. This mapping is done by the MMU(memory
management Unit) with the help of the segment table.
Lets first understand some of the basic terms then we will see how this
translation is done.
Logical Address: The logical address consists of two parts segment number
and page offset.
1. Segment Number: It tells the specific segment of the process from which
the CPU wants to read the data.
2. Segment Offset: It tells the exact word in that segment which the CPU
wants to read.
Logical Address = Segment Number + Segment Offset
Physical Address: The physical address is obtained by adding the base address
of the segment to the segment offset.
Segment table: A segment table stores the base address of each segment in
the main memory. It has two parts i.e. Base and Limit. Here, base indicates the base
address or starting address of the segment in the main memory. Limit tells the size
of that segment. A register called Segment Table Base Register(STBR) which holds
the base value of the segment table. The segment table is also stored in the main
memory itself.
How is the translation done?
The CPU generates the logical address which contains the segment number
and the segment offset. STBR register contains the address of the segment table.
Now, the segment table helps in determining the base address of the segment
corresponding to the page number. Now, the segment offset is compared with the
limit corresponding to the Base. If the segment offset is greater than the limit then
it is an invalid address. This is because the CPU is trying to access a word in the
segment and this value is greater than the size of the segment itself which is not
possible. If the segment offset is less than or equal to the limit then only the
request is accepted. The physical address is generated by adding the base address
of the segment to the segment offset.
Advantages of Segmentation
• The size of the segment table is less compared to the size of the page
table.
• There is no internal fragmentation.
Disadvantages of Segmentation
• When the processes are loaded and removed ( during swapping ) from
the main memory then free memory spaces are broken into smaller
pieces and this causes external fragmentation.
• Here also the time to access the data increases as due to segmentation
the main memory has to be now accessed two times. First, we need to
access the segment table which is also stored in the main memory and
second, combine the base address of the segment with the segment
offset and then get the physical address which is again stored in the
main memory.

More Related Content

Similar to CSI-503 - 8.Paging and Segmentation

Similar to CSI-503 - 8.Paging and Segmentation (20)

UNIT-2 OS.pptx
UNIT-2 OS.pptxUNIT-2 OS.pptx
UNIT-2 OS.pptx
 
Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory management
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Memory comp
Memory compMemory comp
Memory comp
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
PAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docxPAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docx
 
Memory management
Memory managementMemory management
Memory management
 
Paging & segmentation; advantages and disadvantage
Paging & segmentation; advantages and disadvantagePaging & segmentation; advantages and disadvantage
Paging & segmentation; advantages and disadvantage
 
unit5_os (1).pptx
unit5_os (1).pptxunit5_os (1).pptx
unit5_os (1).pptx
 
VIRTUAL MEMORY
VIRTUAL MEMORYVIRTUAL MEMORY
VIRTUAL MEMORY
 
virtual memoey.pptx
virtual memoey.pptxvirtual memoey.pptx
virtual memoey.pptx
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Cs416 08 09a
Cs416 08 09aCs416 08 09a
Cs416 08 09a
 
Memory Management Strategies - III.pdf
Memory Management Strategies - III.pdfMemory Management Strategies - III.pdf
Memory Management Strategies - III.pdf
 
Os4
Os4Os4
Os4
 
Os4
Os4Os4
Os4
 
Csc4320 chapter 8 2
Csc4320 chapter 8 2Csc4320 chapter 8 2
Csc4320 chapter 8 2
 
Vm
VmVm
Vm
 

More from ghayour abbas

Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)ghayour abbas
 
Web Development 3 (HTML & CSS)
Web Development 3  (HTML & CSS)Web Development 3  (HTML & CSS)
Web Development 3 (HTML & CSS)ghayour abbas
 
Web Development 2 (HTML & CSS)
Web Development 2 (HTML & CSS)Web Development 2 (HTML & CSS)
Web Development 2 (HTML & CSS)ghayour abbas
 
Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)ghayour abbas
 
CSI-503 - 13. Scheduler and Dispatcher
CSI-503 - 13. Scheduler and Dispatcher CSI-503 - 13. Scheduler and Dispatcher
CSI-503 - 13. Scheduler and Dispatcher ghayour abbas
 
CSI-503 - 11.Distributed Operating System
CSI-503 - 11.Distributed Operating SystemCSI-503 - 11.Distributed Operating System
CSI-503 - 11.Distributed Operating Systemghayour abbas
 
SWE-401 - 10. Software Testing Overview
SWE-401 - 10. Software Testing OverviewSWE-401 - 10. Software Testing Overview
SWE-401 - 10. Software Testing Overviewghayour abbas
 
SWE-401 - 9. Software Implementation
SWE-401 - 9. Software ImplementationSWE-401 - 9. Software Implementation
SWE-401 - 9. Software Implementationghayour abbas
 
SWE-401 - 8. Software User Interface Design
SWE-401 - 8. Software User Interface DesignSWE-401 - 8. Software User Interface Design
SWE-401 - 8. Software User Interface Designghayour abbas
 
SWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design StrategiesSWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design Strategiesghayour abbas
 
SWE-401 - 5. Software Design Basics
SWE-401 - 5. Software Design BasicsSWE-401 - 5. Software Design Basics
SWE-401 - 5. Software Design Basicsghayour abbas
 
SWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design ToolsSWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design Toolsghayour abbas
 
SWE-401 - 4. Software Requirement Specifications
SWE-401 - 4. Software Requirement Specifications SWE-401 - 4. Software Requirement Specifications
SWE-401 - 4. Software Requirement Specifications ghayour abbas
 
SWE-401 - 3. Software Project Management
SWE-401 - 3. Software Project ManagementSWE-401 - 3. Software Project Management
SWE-401 - 3. Software Project Managementghayour abbas
 
CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management ghayour abbas
 
CSI-503 - 4. Process synchronization
CSI-503 - 4. Process synchronizationCSI-503 - 4. Process synchronization
CSI-503 - 4. Process synchronizationghayour abbas
 

More from ghayour abbas (20)

TCP/IP & UDP
TCP/IP & UDPTCP/IP & UDP
TCP/IP & UDP
 
Web Development 5
Web Development 5 Web Development 5
Web Development 5
 
Web Development 4
Web Development 4Web Development 4
Web Development 4
 
Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)Web Development 4 (HTML & CSS)
Web Development 4 (HTML & CSS)
 
Web Development 3 (HTML & CSS)
Web Development 3  (HTML & CSS)Web Development 3  (HTML & CSS)
Web Development 3 (HTML & CSS)
 
Lab Manual CSI-321
Lab Manual CSI-321Lab Manual CSI-321
Lab Manual CSI-321
 
Web Development 2 (HTML & CSS)
Web Development 2 (HTML & CSS)Web Development 2 (HTML & CSS)
Web Development 2 (HTML & CSS)
 
Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)Web Development 1 (HTML & CSS)
Web Development 1 (HTML & CSS)
 
CSI-503 - 13. Scheduler and Dispatcher
CSI-503 - 13. Scheduler and Dispatcher CSI-503 - 13. Scheduler and Dispatcher
CSI-503 - 13. Scheduler and Dispatcher
 
CSI-503 - 11.Distributed Operating System
CSI-503 - 11.Distributed Operating SystemCSI-503 - 11.Distributed Operating System
CSI-503 - 11.Distributed Operating System
 
SWE-401 - 10. Software Testing Overview
SWE-401 - 10. Software Testing OverviewSWE-401 - 10. Software Testing Overview
SWE-401 - 10. Software Testing Overview
 
SWE-401 - 9. Software Implementation
SWE-401 - 9. Software ImplementationSWE-401 - 9. Software Implementation
SWE-401 - 9. Software Implementation
 
SWE-401 - 8. Software User Interface Design
SWE-401 - 8. Software User Interface DesignSWE-401 - 8. Software User Interface Design
SWE-401 - 8. Software User Interface Design
 
SWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design StrategiesSWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design Strategies
 
SWE-401 - 5. Software Design Basics
SWE-401 - 5. Software Design BasicsSWE-401 - 5. Software Design Basics
SWE-401 - 5. Software Design Basics
 
SWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design ToolsSWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design Tools
 
SWE-401 - 4. Software Requirement Specifications
SWE-401 - 4. Software Requirement Specifications SWE-401 - 4. Software Requirement Specifications
SWE-401 - 4. Software Requirement Specifications
 
SWE-401 - 3. Software Project Management
SWE-401 - 3. Software Project ManagementSWE-401 - 3. Software Project Management
SWE-401 - 3. Software Project Management
 
CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management
 
CSI-503 - 4. Process synchronization
CSI-503 - 4. Process synchronizationCSI-503 - 4. Process synchronization
CSI-503 - 4. Process synchronization
 

Recently uploaded

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

CSI-503 - 8.Paging and Segmentation

  • 1. 8 Paging and Segmentation Prepared By: Ghayour Abbas External fragmentation occurs because we allocate memory continuously to the processes. Due to this space is left and memory remains unused hence, cause external fragmentation. So to tackle this problem the concept of paging was introduced where we divide the process into small pages and these pages are allocated memory non-contiguously into the RAM. Non-Contiguous Memory Allocation Technique In the non-contiguous memory allocation technique, different parts of the same process are stored in different places of the main memory. Types: • Paging • Segmentation Paging Paging is a non-contiguous memory allocation technique in which secondary memory and the main memory is divided into equal size partitions. The partitions of the secondary memory are called pages while the partitions of the main memory are called frames. They are divided into equal size partitions to have maximum utilization of the main memory and avoid external fragmentation.
  • 2. Translation of logical Address into physical Address As a CPU always generates a logical address and we need a physical address for accessing the main memory. This mapping is done by the MMU(memory management Unit) with the help of the page table. Lets first understand some of the basic terms then we will see how this translation is done. Logical Address: The logical address consists of two parts page number and page offset. 1. Page Number: It tells the exact page of the process which the CPU wants to access. 2. Page Offset: It tells the exact word on that page which the CPU wants to read. Logical Address = Page Number + Page Offset Physical Address: The physical address consists of two parts frame number and page offset. 1. Frame Number: It tells the exact frame where the page is stored in physical memory. 2. Page Offset: It tells the exact word on that page which the CPU wants to read. It requires no translation as the page size is the same as the frame size so the place of the word which CPU wants access will not change. Physical Address = Frame Number + Page Offset Page table: A page stable contains the frame number corresponding to the page number of some specific process. So, each process will have its own page table. A register called Page Table Base Register(PTBR) which holds the base value of the page table.
  • 3. Now, let's see how the translation is done. How is the translation done? The CPU generates the logical address which contains the page number and the page offset. The PTBR register contains the address of the page table. Now, the page table helps in determining the frame number corresponding to the page number. Now, with the help of frame number and the page offset the physical address is determined and the page is accessed in the main memory.
  • 4. Advantages of Paging • There is no external fragmentation as it allows us to store the data in a non- contiguous way. • Swapping is easy between equal-sized pages and frames. Disadvantages of Paging • As the size of the frame is fixed, so it may suffer from internal fragmentation. It may happen that the process is too small and it may not acquire the entire frame size. • The access time increases because of paging as the main memory has to be now accessed two times. First, we need to access the page table which is also stored in the main memory and second, combine the frame number with the page offset and then get the physical address of the page which is again stored in the main memory. • For every process, we have an independent page table and maintaining the page table is extra overhead. Segmentation In paging, we were blindly diving the process into pages of fixed sizes but in segmentation, we divide the process into modules for better visualization of the process. Here each segment or module consists of the same type of functions. For example, the main function is included in one segment, library function is kept in other segments, and so on. As the size of segments may vary, so memory is divided into variable size parts. Translation of logical Address into physical Address As a CPU always generates a logical address and we need a physical address for accessing the main memory. This mapping is done by the MMU(memory management Unit) with the help of the segment table.
  • 5. Lets first understand some of the basic terms then we will see how this translation is done. Logical Address: The logical address consists of two parts segment number and page offset. 1. Segment Number: It tells the specific segment of the process from which the CPU wants to read the data. 2. Segment Offset: It tells the exact word in that segment which the CPU wants to read. Logical Address = Segment Number + Segment Offset Physical Address: The physical address is obtained by adding the base address of the segment to the segment offset. Segment table: A segment table stores the base address of each segment in the main memory. It has two parts i.e. Base and Limit. Here, base indicates the base address or starting address of the segment in the main memory. Limit tells the size of that segment. A register called Segment Table Base Register(STBR) which holds the base value of the segment table. The segment table is also stored in the main memory itself. How is the translation done? The CPU generates the logical address which contains the segment number and the segment offset. STBR register contains the address of the segment table. Now, the segment table helps in determining the base address of the segment corresponding to the page number. Now, the segment offset is compared with the limit corresponding to the Base. If the segment offset is greater than the limit then it is an invalid address. This is because the CPU is trying to access a word in the segment and this value is greater than the size of the segment itself which is not possible. If the segment offset is less than or equal to the limit then only the request is accepted. The physical address is generated by adding the base address of the segment to the segment offset.
  • 6. Advantages of Segmentation • The size of the segment table is less compared to the size of the page table. • There is no internal fragmentation. Disadvantages of Segmentation • When the processes are loaded and removed ( during swapping ) from the main memory then free memory spaces are broken into smaller pieces and this causes external fragmentation. • Here also the time to access the data increases as due to segmentation the main memory has to be now accessed two times. First, we need to access the segment table which is also stored in the main memory and second, combine the base address of the segment with the segment offset and then get the physical address which is again stored in the main memory.