SlideShare a Scribd company logo
 The main purpose of a computer system is to execute programs.
These programs, together with the data they access, must be in
main memory (at least partially) during execution.
 Main memory and the registers built into the processor itself are
the only storage that the CPU can access directly.
 Registers are generally accessible within one cycle of the CPU
clock. The same cannot be said of main memory, which is
accessed via a transaction on the memory bus.
 Memory access may take many clock cycles to complete, in
which case the processor normally needs to stall, since it does
not have the data required to complete the instruction that it is
executing.
 Usually, a program resides on a disk as a binary executable file.
To be executed, the program must be brought into memory.
 The process of associating program instructions and data
to physical memory addresses is called address binding,
or relocation.
 Addresses in the source program are generally relocatable
addresses generated by the compiler.
 Loader will in turn bind the relocatable addresses to absolute
addresses.
 Each binding is a mapping from one address space to another.
 User processes must be
restricted so that they only
access memory locations that
"belong" to that particular
process.
 This is usually implemented
using a base register and a
limit register for each process.
 Every memory access made by
a user process is checked
against these two registers, and
if a memory access is
attempted outside the valid
range, then a fatal error is
generated.
Changing the contents of the base and limit registers is a privileged
activity, allowed only to the OS kernel.
 Classically, the binding of program addresses can be done at any
step along the way:
 Compile time: The compiler translates symbolic addresses to
absolute addresses. If you know at compile time where the
process will reside in memory, then absolute addresses can be
generated (Static).
 For example, if we know that a user process will reside starting
at location R, then the generated compiler code will start at that
location and extend up from there. If, at some later time, the
starting location changes, then it will be necessary to recompile
this code.
 Load time: If it is not known at compile time where the process
will reside in memory, then the compiler must generate
relocatable code. In this case, final binding is delayed until
load time.
 It references addresses relative to the start of the program.
 If the starting address changes in RAM, then the program must
be reloaded but not recompiled.
Relative (Relocatable)
Addresses
0
JUMP 400
LOAD 1200
400
1200
Relative Load Module
Symbolic
Addresses
PROGRAM
JUMP i
LOAD j
DATA
i
j
Source Code
Compile Link
 Execution time: If the process can be moved during its
execution from one memory segment to another, then binding
must be delayed until run time.
 Special hardware must be available for this scheme to work.
Most general-purpose operating systems use this method.
◦ Logical address – generated by the CPU; also referred to as
virtual address
◦ Physical address – address seen by the memory unit.
Actual addresses of RAM
 Logical and physical addresses are the same in compile-time
and load-time address-binding schemes; logical (virtual) and
physical addresses differ in execution-time address-binding
scheme
 Hardware device that maps virtual to physical address
 In MMU scheme, the value in the relocation register is added
to every address generated by a user process at the time it is
sent to memory
 The user program deals with logical addresses; it never sees
the real physical addresses
 A process can be swapped temporarily out of memory to a
backing store, and then brought back into memory for
continued execution.
 Backing store – fast disk large enough to accommodate
copies of all memory images for all users; must provide direct
access to these memory images
 Roll out, roll in –
swapping variant used
for priority-based schedu
ling algorithms; lower-pri
ority process is swapped
out so higher-priority
process can be loaded
and executed
Major part of swap time is transfer time; total transfer time is
directly proportional to the amount of memory swapped.
 A modification of swapping is used in many versions of UNIX.
Swapping is normally disabled but will start if many processes
are running and are using a threshold amount of memory.
 Swapping is again halted when the load on the system is
reduced.
 External Fragmentation – total memory space exists to
satisfy a request, but it is not contiguous
 Internal Fragmentation – allocated memory may be slightly
larger than requested memory; this size difference is memory
internal to a partition, but not being used
 Reduce external fragmentation by compaction
◦ Shuffle memory contents to place all free memory together in
one large block
◦ Compaction is possible only if relocation is dynamic, and is
done at execution time
OS
P1
P2
P3
OS
P1
P3
OS
P1
P3
P4
OS
P3
P4
OS
P3
P4
P5
OS
P1
OS
P1
P2
OS OS
P3
P4
P5
P6
compaction
 Divide physical memory into fixed-
sized blocks called frames (size is
power of 2, between 512 bytes and
8192 bytes)
 Divide logical memory into blocks of
same size called pages.
 Any virtual page can be located at any
physical page
 Translation box converts from virtual
pages to physical pages
0
1
2
3
4
5
0
1
2
3
0
1
2
3
4
5
6
7
8
9
10
11
12
13
Translation
Virtual
Page #
Physical
Page #
0x0000
0x6000
0x0000
0x4000
0x0000
0xE000
 Address generated by CPU is divided into:
◦ Page number (p) – used as an index into a page table
which contains base address of each page in physical
memory
◦ Page offset (d) – combined with base address to define the
physical memory address that is sent to the memory unit
Page Size=
4bytes
Physical
Memory=
32bytes
 In paging we have no external fragmentation. Any free frame
can be allocated to a process that needs it. However, we may
have some internal fragmentation?
 Today, pages typically are between 4 KB and 8 KB in size, and some
systems support even larger page sizes.
 Important aspect of paging is the clear separation between the
user’s view of memory and the actual physical memory.
 The user program views memory as one single space, containing
only this one program. In fact, the user program is scattered
throughout physical memory, which also holds other programs.

More Related Content

Similar to Lecture20-21-22.ppt

Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OSC.U
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
Operating Systems - memory management
Operating Systems - memory managementOperating Systems - memory management
Operating Systems - memory management
Mukesh Chinta
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
Wayne Jones Jnr
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OSC.U
 
Operating system
Operating systemOperating system
Operating system
Hussain Ahmady
 
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
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
rprajat007
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
Arnav Chowdhury
 
Memory Managment(OS).pptx
Memory Managment(OS).pptxMemory Managment(OS).pptx
Memory Managment(OS).pptx
RohitPaul71
 
Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742
marangburu42
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
SourabhRaj29
 
Memory management
Memory managementMemory management
Memory management
cpjcollege
 
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
 
virtual memory
virtual memoryvirtual memory
virtual memory
Abeer Naskar
 

Similar to Lecture20-21-22.ppt (20)

Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
OSCh9
OSCh9OSCh9
OSCh9
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
Operating Systems - memory management
Operating Systems - memory managementOperating Systems - memory management
Operating Systems - memory management
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Ch8
Ch8Ch8
Ch8
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
 
Operating system
Operating systemOperating system
Operating system
 
Main memory os - prashant odhavani- 160920107003
Main memory   os - prashant odhavani- 160920107003Main memory   os - prashant odhavani- 160920107003
Main memory os - prashant odhavani- 160920107003
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
 
Memory Managment(OS).pptx
Memory Managment(OS).pptxMemory Managment(OS).pptx
Memory Managment(OS).pptx
 
Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742Mainmemoryfinalprefinal 160927115742
Mainmemoryfinalprefinal 160927115742
 
Memory+management
Memory+managementMemory+management
Memory+management
 
Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
 
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
 
virtual memory
virtual memoryvirtual memory
virtual memory
 

Recently uploaded

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
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
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
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
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
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
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
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
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

Lecture20-21-22.ppt

  • 1.
  • 2.  The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory (at least partially) during execution.  Main memory and the registers built into the processor itself are the only storage that the CPU can access directly.  Registers are generally accessible within one cycle of the CPU clock. The same cannot be said of main memory, which is accessed via a transaction on the memory bus.  Memory access may take many clock cycles to complete, in which case the processor normally needs to stall, since it does not have the data required to complete the instruction that it is executing.
  • 3.  Usually, a program resides on a disk as a binary executable file. To be executed, the program must be brought into memory.  The process of associating program instructions and data to physical memory addresses is called address binding, or relocation.  Addresses in the source program are generally relocatable addresses generated by the compiler.  Loader will in turn bind the relocatable addresses to absolute addresses.  Each binding is a mapping from one address space to another.
  • 4.
  • 5.  User processes must be restricted so that they only access memory locations that "belong" to that particular process.  This is usually implemented using a base register and a limit register for each process.  Every memory access made by a user process is checked against these two registers, and if a memory access is attempted outside the valid range, then a fatal error is generated.
  • 6. Changing the contents of the base and limit registers is a privileged activity, allowed only to the OS kernel.
  • 7.  Classically, the binding of program addresses can be done at any step along the way:  Compile time: The compiler translates symbolic addresses to absolute addresses. If you know at compile time where the process will reside in memory, then absolute addresses can be generated (Static).  For example, if we know that a user process will reside starting at location R, then the generated compiler code will start at that location and extend up from there. If, at some later time, the starting location changes, then it will be necessary to recompile this code.
  • 8.
  • 9.
  • 10.  Load time: If it is not known at compile time where the process will reside in memory, then the compiler must generate relocatable code. In this case, final binding is delayed until load time.  It references addresses relative to the start of the program.  If the starting address changes in RAM, then the program must be reloaded but not recompiled.
  • 11. Relative (Relocatable) Addresses 0 JUMP 400 LOAD 1200 400 1200 Relative Load Module Symbolic Addresses PROGRAM JUMP i LOAD j DATA i j Source Code Compile Link
  • 12.
  • 13.  Execution time: If the process can be moved during its execution from one memory segment to another, then binding must be delayed until run time.  Special hardware must be available for this scheme to work. Most general-purpose operating systems use this method.
  • 14.
  • 15. ◦ Logical address – generated by the CPU; also referred to as virtual address ◦ Physical address – address seen by the memory unit. Actual addresses of RAM  Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme
  • 16.  Hardware device that maps virtual to physical address  In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory  The user program deals with logical addresses; it never sees the real physical addresses
  • 17.
  • 18.  A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution.  Backing store – fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images  Roll out, roll in – swapping variant used for priority-based schedu ling algorithms; lower-pri ority process is swapped out so higher-priority process can be loaded and executed
  • 19. Major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped.  A modification of swapping is used in many versions of UNIX. Swapping is normally disabled but will start if many processes are running and are using a threshold amount of memory.  Swapping is again halted when the load on the system is reduced.
  • 20.  External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous  Internal Fragmentation – allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used  Reduce external fragmentation by compaction ◦ Shuffle memory contents to place all free memory together in one large block ◦ Compaction is possible only if relocation is dynamic, and is done at execution time OS P1 P2 P3 OS P1 P3 OS P1 P3 P4 OS P3 P4 OS P3 P4 P5 OS P1 OS P1 P2 OS OS P3 P4 P5 P6 compaction
  • 21.  Divide physical memory into fixed- sized blocks called frames (size is power of 2, between 512 bytes and 8192 bytes)  Divide logical memory into blocks of same size called pages.  Any virtual page can be located at any physical page  Translation box converts from virtual pages to physical pages 0 1 2 3 4 5 0 1 2 3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Translation Virtual Page # Physical Page # 0x0000 0x6000 0x0000 0x4000 0x0000 0xE000
  • 22.  Address generated by CPU is divided into: ◦ Page number (p) – used as an index into a page table which contains base address of each page in physical memory ◦ Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit
  • 23.
  • 25.  In paging we have no external fragmentation. Any free frame can be allocated to a process that needs it. However, we may have some internal fragmentation?  Today, pages typically are between 4 KB and 8 KB in size, and some systems support even larger page sizes.  Important aspect of paging is the clear separation between the user’s view of memory and the actual physical memory.  The user program views memory as one single space, containing only this one program. In fact, the user program is scattered throughout physical memory, which also holds other programs.