SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Operating System-Memory
      Management

          by
      Vishal Singh
     (Vishalchd11@yahoo.com)
Why Memory management ?
1. To ensure protection of different
   processes from each other (so that
   they do not interfere with each other’s
   operations).
2. To place the programs in memory
   (such that memory is utilized to its
   fullest extent.
Logical vs. physical address
               space
► A logical address is the address of an
 instruction or data as used by a program.

► A physical address is the effective memory
 address of an instruction or data i.e. it is the
 address obtained after binding of logical
 addresses has been done.
Program relocation
Relocation register
► Relocation register is a special register in
  the CPU used for program relocation means
  mapping of logical addresses used by the
  program to physical addresses of the
  system’s main memory
Storage Allocation and
    Management Techniques
The Storage allocation can be of two types:

 (i) Contiguous storage allocation.

 (ii) Non-contiguous storage allocation.
Contiguous Storage Allocation
► Contiguous storage allocation implies that a
  program’s data and instructions are assured
  to occupy a single contiguous memory area.
► It is further subdivided into Fixed-partition
  storage allocation strategy and variable-
  partition storage allocation strategy.
1. Fixed-partition contiguous
       storage allocation

► processes with small address space use
 small partitions and processes with large
 address space use large partitions. This is
 known as fixed partition contiguous storage
 allocation.
2. Variable - partition
contiguous storage allocation

This notion is derived from parking of vehicles on
the sides of streets where the one who manages
to enter will get the space. Two vehicles can
leave a space between them that cannot be used
by any vehicle. This means that whenever a
process needs memory, a search for the space
needed by it, is done. If contiguous space is
available to accommodate that process, then the
process is loaded into memory.
External Fragmentation
► This phenomenon of entering and leaving
 the memory can cause the formation of
 unusable memory holes (like the unused
 space between two vehicles). This is
 known as External Fragmentation.
Three strategies that can be used to
 allocate memory to Variable - partition
They are the following:

1. Best - Fit
2. Worst - fit
3. First - fit
Best - Fit - chooses a partition that is smallest and whose
     size is greater than equal to k. It leaves small-sized
     unusable partitions or holes.
First - fit - chooses the first partition whose
    size is greater than equal to k.
Worst - fit - chooses the largest partition and
   allocates it to process p. It can leave bigger
   unusable partitions.
Compaction means to move the processes in the
memory in such a way that scattered pieces of
unused (free) memory can be placed together so
that any other process demanding contiguous
memory for it can use it.
Non-contiguous Storage
          Allocation
► To resolve the problem     of external
 fragmentation and to enhance the
 degree of multiprogramming to a
 greater extent, it was decided to sacrifice
 the simplicity of allocating contiguous
 memory to every process. It was decided to
 have a non-contiguous physical address
 space of a process so that a process could
 be allocated memory wherever it was
 available.
Non-contiguous Storage Allocation
There are 2 techniques for non-contiguous
allocation:
1. Paging
2. Segmentation
1. Paging
► In this approach,physical memory is
 divided into fixed-size blocks called
 frames and the logical memory is
 divided into the fixed-sized blocks
 called pages. The size of a page is
 same as that of frame. The key idea of
 this method is to place the pages of a
 process into the available frames of
 memory, whenever, this process is to be
 executed. The address mapping is done
 by Page table.
Paging example
It works as:
Translate logical address 13 = 01101 in
   binary
Offset = 01 in binary or 1 in decimal
Page no. = 011 in binary or 3 in decimal
Physical address = pageframe*pagesize +
   offset i.e. 2*4+1 = 9 (which is the real
   address of page containing character “n”
   in the main memory)
Problem with paging
► It uses a page table per process for
  translating logical to physical address
  space. A basic issue associated with the
  use of page table is, that the look up in the
  page table should be very fast (which is
  generally slow), as it is done on every
  memory reference.
► So to make the look up time less, caching
  is used. In this case, the specific cache
  device is called a translation look aside
  buffer (TLB).
Translation look aside buffer (TLB).
► The TLB contains a set of entries, each of
  which contains a page number, the
  corresponding frame number, and the
  protection bits.
► So if we use TLB, then mapping is done
  by TLB and we generally find the entry in
  TLB but in case the entry is not found in
  TLB than we have a TLB miss and finally
  we go to page table.
Segmentation
► segmentation is another technique for the
  noncontiguous storage allocation. It is different
  from paging as it supports users’ view of his
  program.
► For a programmer it might be more relevant to
  divide the logical address space of his program
  into variable sized segments (with respect to his
  view of main program, subroutines, data, etc.)
  than to divide it into fixed size pages. Such
  variable sized segments, which are a collection
  of logically related information, are the basis of
  segmentation technique.
Segmentation example
Virtual Memory

► Virtual memory is a technique of executing
  program instructions that may not fit entirely in
  system memory. This is done by calling
  instructions as and when the application requires
  it. Virtual memory is implemented by using
  secondary storage to augment the main
  memory. Data is transferred from secondary to
  main storage as and when necessary and the
  data modified is written back to the secondary
  storage according to a predetermined algorithm.
Swapping
► Swapping is the technique of temporarily
  removing inactive programs from the main
  memory of a computer system. An
  inactive program is one that is neither
  executing nor performing an I/O operation.
► This may also happen when it is desired to
  place a higher-priority process in the
  memory. A lower priority process may be
  swapped out so that higher-priority
  process may be loaded and executed.
Demand Paging
► In virtual memory system, demand paging is a
  type of swapping in which pages of programs
  are not copied from disk to main memory until
  they are needed for execution.
► In demand paging, virtual address (logical
  address) is accessed by CPU, the
  corresponding page number is looked up in the
  page table and if it shows that currently this
  page is not in main memory, then this page must
  be brought into the main-memory.
► A page  fault occurs when an invalid
 page is addressed. Page fault must be
 followed by swapping-in the page
 (demanded just now by the CPU) from
 disk to main-memory or a trap should be
 generated to the operating system if the
 page being demanded is not within the
 logical address space of the process. To
 determine whether the reference to the
 requested page is within the logical
 address space or not, an internal table
 may be consulted
Pure Demand Paging
► Pure demand paging is the form of
 demand paging in which not even a
 single page is loaded into memory,
 initially. Thus, the very first instruction
 causes a page fault in this case. This kind
 of demand paging may significantly
 decrease the performance of a computer
 system by generally increasing the
 effective access time of memory.
Page Replacement
► Once the main memory fills up, a page
  must be swapped out to make room for
  any pages to be swapped in. This is
  known as page replacement.
► We have page replacement algorithms for
  page replacement purpose, which are as
  follows:
1.   The optimal page replacement
     algorithm
2.   The first-in, first-out (FIFO) page
     replacement algorithm
3.   The second chance page replacement
     algorithm
4.   The least recently used (LRU) page
     replacement algorithm
5.   Simulating LRU in Software (Not frequently
     used algorithm)
6.   The Working Set Page Replacement
     Algorithm

Weitere ähnliche Inhalte

Was ist angesagt?

Memory management ppt
Memory management pptMemory management ppt
Memory management pptManishaJha43
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-SystemsVenkata Sreeram
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory managementrprajat007
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSKumar Pritam
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
Segmentation in Operating Systems.
Segmentation in Operating Systems.Segmentation in Operating Systems.
Segmentation in Operating Systems.Muhammad SiRaj Munir
 
Process management os concept
Process management os conceptProcess management os concept
Process management os conceptpriyadeosarkar91
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Memory management
Memory managementMemory management
Memory managementcpjcollege
 
Chapter 10 - File System Interface
Chapter 10 - File System InterfaceChapter 10 - File System Interface
Chapter 10 - File System InterfaceWayne Jones Jnr
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structuresMukesh Chinta
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentationhamza haseeb
 

Was ist angesagt? (20)

Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
System call
System callSystem call
System call
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Segmentation in Operating Systems.
Segmentation in Operating Systems.Segmentation in Operating Systems.
Segmentation in Operating Systems.
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Memory management
Memory managementMemory management
Memory management
 
Chapter 10 - File System Interface
Chapter 10 - File System InterfaceChapter 10 - File System Interface
Chapter 10 - File System Interface
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structures
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentation
 

Andere mochten auch

Andere mochten auch (20)

Virtual Memory and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and Paging
 
Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
Data structure lecture 1
Data structure   lecture 1Data structure   lecture 1
Data structure lecture 1
 
Linkers And Loaders
Linkers And LoadersLinkers And Loaders
Linkers And Loaders
 
Program Structure in GNU/Linux (ELF Format)
Program Structure in GNU/Linux (ELF Format)Program Structure in GNU/Linux (ELF Format)
Program Structure in GNU/Linux (ELF Format)
 
PE File Format
PE File FormatPE File Format
PE File Format
 
04 Cache Memory
04  Cache  Memory04  Cache  Memory
04 Cache Memory
 
Paging
PagingPaging
Paging
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Software engineering introduction
Software engineering introductionSoftware engineering introduction
Software engineering introduction
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Operating System-Memory Management
Operating System-Memory ManagementOperating System-Memory Management
Operating System-Memory Management
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Coding
CodingCoding
Coding
 
Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence Knowledge Representation in Artificial intelligence
Knowledge Representation in Artificial intelligence
 
Memory management
Memory managementMemory management
Memory management
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AI
 

Ähnlich wie OS Memory Management Techniques

Ähnlich wie OS Memory Management Techniques (20)

OSCh9
OSCh9OSCh9
OSCh9
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
Paging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory managementPaging +Algorithem+Segmentation+memory management
Paging +Algorithem+Segmentation+memory management
 
Memory management
Memory managementMemory management
Memory management
 
UNIT-2 OS.pptx
UNIT-2 OS.pptxUNIT-2 OS.pptx
UNIT-2 OS.pptx
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
 
Os unit 3
Os unit 3Os unit 3
Os unit 3
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
 
unit5_os (1).pptx
unit5_os (1).pptxunit5_os (1).pptx
unit5_os (1).pptx
 
Memory management Assignment Help
Memory management Assignment HelpMemory management Assignment Help
Memory management Assignment Help
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Ch8
Ch8Ch8
Ch8
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Bab 4
Bab 4Bab 4
Bab 4
 

Kürzlich hochgeladen

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
“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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Kürzlich hochgeladen (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
“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...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
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
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

OS Memory Management Techniques

  • 1. Operating System-Memory Management by Vishal Singh (Vishalchd11@yahoo.com)
  • 2. Why Memory management ? 1. To ensure protection of different processes from each other (so that they do not interfere with each other’s operations). 2. To place the programs in memory (such that memory is utilized to its fullest extent.
  • 3. Logical vs. physical address space ► A logical address is the address of an instruction or data as used by a program. ► A physical address is the effective memory address of an instruction or data i.e. it is the address obtained after binding of logical addresses has been done.
  • 5. Relocation register ► Relocation register is a special register in the CPU used for program relocation means mapping of logical addresses used by the program to physical addresses of the system’s main memory
  • 6. Storage Allocation and Management Techniques The Storage allocation can be of two types: (i) Contiguous storage allocation. (ii) Non-contiguous storage allocation.
  • 7. Contiguous Storage Allocation ► Contiguous storage allocation implies that a program’s data and instructions are assured to occupy a single contiguous memory area. ► It is further subdivided into Fixed-partition storage allocation strategy and variable- partition storage allocation strategy.
  • 8. 1. Fixed-partition contiguous storage allocation ► processes with small address space use small partitions and processes with large address space use large partitions. This is known as fixed partition contiguous storage allocation.
  • 9.
  • 10. 2. Variable - partition contiguous storage allocation This notion is derived from parking of vehicles on the sides of streets where the one who manages to enter will get the space. Two vehicles can leave a space between them that cannot be used by any vehicle. This means that whenever a process needs memory, a search for the space needed by it, is done. If contiguous space is available to accommodate that process, then the process is loaded into memory.
  • 11. External Fragmentation ► This phenomenon of entering and leaving the memory can cause the formation of unusable memory holes (like the unused space between two vehicles). This is known as External Fragmentation.
  • 12. Three strategies that can be used to allocate memory to Variable - partition They are the following: 1. Best - Fit 2. Worst - fit 3. First - fit
  • 13. Best - Fit - chooses a partition that is smallest and whose size is greater than equal to k. It leaves small-sized unusable partitions or holes.
  • 14. First - fit - chooses the first partition whose size is greater than equal to k.
  • 15. Worst - fit - chooses the largest partition and allocates it to process p. It can leave bigger unusable partitions.
  • 16. Compaction means to move the processes in the memory in such a way that scattered pieces of unused (free) memory can be placed together so that any other process demanding contiguous memory for it can use it.
  • 17. Non-contiguous Storage Allocation ► To resolve the problem of external fragmentation and to enhance the degree of multiprogramming to a greater extent, it was decided to sacrifice the simplicity of allocating contiguous memory to every process. It was decided to have a non-contiguous physical address space of a process so that a process could be allocated memory wherever it was available.
  • 18. Non-contiguous Storage Allocation There are 2 techniques for non-contiguous allocation: 1. Paging 2. Segmentation
  • 19. 1. Paging ► In this approach,physical memory is divided into fixed-size blocks called frames and the logical memory is divided into the fixed-sized blocks called pages. The size of a page is same as that of frame. The key idea of this method is to place the pages of a process into the available frames of memory, whenever, this process is to be executed. The address mapping is done by Page table.
  • 21. It works as: Translate logical address 13 = 01101 in binary Offset = 01 in binary or 1 in decimal Page no. = 011 in binary or 3 in decimal Physical address = pageframe*pagesize + offset i.e. 2*4+1 = 9 (which is the real address of page containing character “n” in the main memory)
  • 22. Problem with paging ► It uses a page table per process for translating logical to physical address space. A basic issue associated with the use of page table is, that the look up in the page table should be very fast (which is generally slow), as it is done on every memory reference. ► So to make the look up time less, caching is used. In this case, the specific cache device is called a translation look aside buffer (TLB).
  • 23. Translation look aside buffer (TLB). ► The TLB contains a set of entries, each of which contains a page number, the corresponding frame number, and the protection bits. ► So if we use TLB, then mapping is done by TLB and we generally find the entry in TLB but in case the entry is not found in TLB than we have a TLB miss and finally we go to page table.
  • 24. Segmentation ► segmentation is another technique for the noncontiguous storage allocation. It is different from paging as it supports users’ view of his program. ► For a programmer it might be more relevant to divide the logical address space of his program into variable sized segments (with respect to his view of main program, subroutines, data, etc.) than to divide it into fixed size pages. Such variable sized segments, which are a collection of logically related information, are the basis of segmentation technique.
  • 26. Virtual Memory ► Virtual memory is a technique of executing program instructions that may not fit entirely in system memory. This is done by calling instructions as and when the application requires it. Virtual memory is implemented by using secondary storage to augment the main memory. Data is transferred from secondary to main storage as and when necessary and the data modified is written back to the secondary storage according to a predetermined algorithm.
  • 27. Swapping ► Swapping is the technique of temporarily removing inactive programs from the main memory of a computer system. An inactive program is one that is neither executing nor performing an I/O operation. ► This may also happen when it is desired to place a higher-priority process in the memory. A lower priority process may be swapped out so that higher-priority process may be loaded and executed.
  • 28.
  • 29. Demand Paging ► In virtual memory system, demand paging is a type of swapping in which pages of programs are not copied from disk to main memory until they are needed for execution. ► In demand paging, virtual address (logical address) is accessed by CPU, the corresponding page number is looked up in the page table and if it shows that currently this page is not in main memory, then this page must be brought into the main-memory.
  • 30. ► A page fault occurs when an invalid page is addressed. Page fault must be followed by swapping-in the page (demanded just now by the CPU) from disk to main-memory or a trap should be generated to the operating system if the page being demanded is not within the logical address space of the process. To determine whether the reference to the requested page is within the logical address space or not, an internal table may be consulted
  • 31.
  • 32.
  • 33. Pure Demand Paging ► Pure demand paging is the form of demand paging in which not even a single page is loaded into memory, initially. Thus, the very first instruction causes a page fault in this case. This kind of demand paging may significantly decrease the performance of a computer system by generally increasing the effective access time of memory.
  • 34. Page Replacement ► Once the main memory fills up, a page must be swapped out to make room for any pages to be swapped in. This is known as page replacement. ► We have page replacement algorithms for page replacement purpose, which are as follows:
  • 35. 1. The optimal page replacement algorithm 2. The first-in, first-out (FIFO) page replacement algorithm 3. The second chance page replacement algorithm 4. The least recently used (LRU) page replacement algorithm 5. Simulating LRU in Software (Not frequently used algorithm) 6. The Working Set Page Replacement Algorithm