SlideShare a Scribd company logo
1 of 55
11
Overview
 Basic Requirements
 Program Translation and address
translation
 Overlaying
 Swapping
 Contiguous memory allocation
 Memory allocation methods
22
 Logical vs. Physical Address Space
 Paging
 Segmentation
33
44
Any mechanism and policy associated
with memory management should satisfy
certain requirements. These requirements
are as follows:
 Relocation
 Protection
 Sharing
55
 The main memory is shared among
different processes in multi programming.
 It is not possible to know that where the
program will be load in main memory
when it is executed.
 The processes are also swapped in and
swapped out of main memory for
maximum utilization of processor.
66
The operating system need to know that
the location of the process control
information and execution stack.
The process of converting the Logical
address into Physical address is known as
Relocation.
77
In main memory many processes
being executed at one time.
Each process must be protected
against unwanted interference by
other processes.
The program in other processes should
not be able to reference the memory
location in a process to read and write
without permission.
88
The memory protection must be relaxed in
some cases.
Some time several processes may be
executing the same program such as an
editor.
The processes that cooperate to solve a
problem may want to access shared data
structures.
99
The processes that will participate in the
sharing must declare shared memory
segments.
The operating system is responsible for
protecting the shared memory from
unauthorized access by other processes.
1010
A process has a logical address space.
It is linear set of locations for program code,
variable and, stack and etc.
As the program executes, all parts of the
logical address space is mapped to a
physical address space.
Physical address space is a subset of primary
memory.
1111
The address space is a product of the
translation-linking-loading process.
Different types of addresses are as
follows:
 Symbolic addresses
 Logical addresses
 Relative addresses
 Physical addresses
1212
An address generated by the CPU is commonly
referred to as a Logical address where as an
address seen by the memory unit-that is, the one
loaded into the memory –address register of the
memory is commonly referred to as the Physical
address.
the set of all logical address generated by a
program from the Logical address space of the
process . The set of all Physical addresses
corresponding to these logical addresses is a
physical address space of the process.
1313
The total size of physical address space in
a system is equal to the size of main
memory.
The run-time mapping from virtual to
physical addresses is done by a piece of
hardware in the CPU, called the
memory management unit (MMU).
1414
Relocation
method
14000
+CPU
Physical
address
14348
Logical
address
346
MMU
process
1515
Translation of a source program in a
high-level assembly language involves
compilation and linking of a program.
This process generates the machine
language executable code (also known as
binary image) for the give source program.
To execute the binary code, it is loaded into
the main memory and the CPU state is set
appropriately.
1616
The whole process is
shown in the
following diagram.
Compile/Assemble
Link
Load
Execute
1717
The collection of processes that is waiting on
the disk to be brought into the memory for
execution forms the Input queue.
In most cases a user program will go through
several steps –some of which may be optional-
before being executed.
Address may be bound in different ways.
1818
Address can be bound in instruction and data
at different time, as discussed below briefly.
 Compile time: if you know at compile
where the process will reside in memory, the
absolute addresses can be assigned to
instructions and data by compiled.
 Load time: if it is not know at compile time
where the processes will reside in memory
then the compiler must generate the re-
locatable code.
1919
 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 work.
In case of compile and load time binding, a
program may not be moved around in
memory at run time.
2020
Source
program
Other object
modules
Load
module
Object
module
Linkage
editor
Loader
compiler or
assembler
Binary memory
image
loader
Dynamically
Loaded system
binary
Compile time
Load time
Execution timeDynamic linking
2121
Overlaying is a technique that is used to
execute a process even if the memory is
not enough.
The operating system can swap overlays
and manage the memory.
The overlays are useful when the program
to be executed is larger then available
memory.
2222
Example
Common
routine
pass2pass1
Symbol
table
Overlay driver
20k
30k
10k
80k70k
2323
 The earliest
computing system
required contiguous
storage allocation in
which each program
occupied single
contiguous memory
block, the technique
of multiprogramming
was not possible.
Main Memory
Process a
Operating
system
Figure of contiguous Memory
Process b
Process c
2424
 In non-contiguous
storage allocation a
program is divided in
several blocks that
may be placed in
different parts of
main memory. It is
difficult for operating
system to control
non-contiguous
storage allocation.
Main Memory
Operating
system
Process a
Process b
Process c
Figure of non contiguous Memory
2525
A process cannot be executed in the CPU unless it
is completely or partly in memory. A process not
executed in CPU can be completely swapped out
of memory to a backing store such as a high-
speed disk.
The swapping is done by swapper.
Dispatcher tries to load a process into CPU and find
that it is not currently in memory.
It will call the swapper to swap the process back
into memory.
2626
Example
P 2
User area
Operating
system
Backing store
Memory
Swap out
Swap in
2727
The main memory must accommodate
both operating system and the various
user space. There are three schemes for
memory allocation these are:
 Single process allocation scheme
 Fixed partition allocation scheme
 Variable partition allocation scheme
2828
 In this scheme only
one process execute
in memory at a time.
The remaining part of
the memory space
will not be used.
User process
…………………
…………………
…………………
…………………
…………………
Unused
Operating
system
Loaded from
main storage
Main Memory
2929
 This scheme
divided memory
into a number of
separate fixed
areas. Each
memory area
could hold one
process.
……………
……………
Process c
300k
……………
…………..
………….
Process b
200k
…………..…………..
Process a
150
Operating
system
Fixed partition
Partition:3
400k
Partition:2
300k
Partition:1
200k
………….
Unused
space
Memory
3030
 The occurrence of
wasted space in
this way is called
internal
fragmentation.
 It is called `Internal’
because it occurs
within the space
allocated to the
process in question.
Process b
Process A
………………..
………………..
Operating
system
……………….
………...…….
Internal
fragmentation
Example
3131
 It is relatively simple to
implementation.
 It facilitates memory
protection mechanism
due to its fixed
partitions.
 The fixed partition sizes
can prevent a process
from being run due to
the unavailability of a
partition of sufficient
size.
 Internal fragmentation
wastes space that
collectively could
accommodate
another process.
Advantages Disadvantages
3232
 It allocate the
exact amount of
memory to the
process as
required.
………………………….
…Available space
………………………….
Operating system
Process A
Process B
Process C
Exact required
Size allocation
3333
 If a new process D is
loaded then it is
allocated adjacent
to process C if
available space is
sufficient.
 When a process
terminates, the
space it occupies is
freed and become
available for the
loading of a new
process.
..………………………
Operating system
Process A
Process B
Process C
Process D New process
Loaded from storage
3434
As processes come and go ,holes of
free space is created in the main
memory. Distribution of free memory
to processes is called External
fragmentation.
External fragmentation refers to the
situation when free memory space
exists to load a process in the memory
but the space is not contiguous.
3535
::::::::::::::::::::::::::::
:::::::::::::::::::::::::::
:::::::::::::::::::::::::::::
Process C
:::::::::::::::::::::::::::
:::::::::::::::::::::::::::
:::::::::::::::::::::::::::
Process A
Operating
system
Termination of process D
And process B leaving
`holes’ in memory
Figure of External Fragmentation
External
Fragmentation
3636
A process that is adjacent to one or more
holes may terminate and free its space
allocation.
The holes can be viewed and utilized as
a single hole. This effect is called
Coalescing holes.
In variable partition the system must keep
track of the position and size of each
hole.
3737
 In this situation
linked list is a helper
key.
 A common
method is use a
linked list.
 A linked list
contains pointers to
the start of each
hole and the hole
size.
size
Process A
Process C
size
NIL
Free holes Linked List
::::::::::::::::::::::::
::::::::::::::::::::::::
::::::::::::::::::::::::
::::::::::::::::::::::::
Operating
system
3838
The fragmentation problem encountered in
the previous method the can be resolved by
physically moving the processes about the
memory in order to close up the holes.
It bring the free space into a single large
block.
This method is called compaction.
3939
Example
Process A
Process C
Process C
Process A
Operating
system
Operating
system
ordered
Memory before compaction Memory after compaction
4040
 A process must be unloaded from
memory if its CPU time-slice has ended. It
is placed in the ready queue to be
loaded again later. It allows the memory
space for another process to be loaded.
A process can change place in memory for
the following three main reasons:
4141
 A process must be unload from memory if
it enters block state by calling I/O
function etc. then it is placed in the block
queue to be loaded later.
 The process may change its position if
compaction is applied.
It must be possible for a process to be
loaded at any address selected by the
operating system.
4242
 The Limit register is used to hold the
highest memory location that a process
can access. By this way, each process is
protected from other processes in
memory.
 A Logical address is expressed as a
location relative to the beginning of the
process. Instructions in the program
contain only logical address.
4343
 A Physical address is an actual location
in main memory.
When a process is loaded in memory, the
physical address of the first location is
put in the base register. All processes are
interpreted as a being relative to this
base address.
4444
a
Physical address
Limit
bProgram address
Base Register
Limit Register
b + a
4545
Physical memory is divided into fixed-size
blocks called frames.
Logical memory is also divided into the same
size blocks called pages.
A single process may require many pages of
memory.
When a process is scheduled for execution, its
pages are loaded into any available memory
frames from the backing store.
4646
The backing store is also divided into
blocks.
The blocks are the same size as the frames
in main memory.
Paging requires additional hardware
support in the form of a page table.
4747
Every logical address generated by the CPU
consist of two parts:
 A Page Number (p)
 A page displacement offset (d)
The page table consist the frame number (f)
of each page in physical memory. The
frame number is combined with the page
offset to obtain the physical memory
address of memory location and object
address by the corresponding logical
address.
4848
 P is use to index the process page table;
page table entry contains the frame
number ,f, where page p is load.
 The physical address of the location
referenced by (p , d) is computed by
appending d at the end of f as shown
below:
ff dd
4949
Assume a logical address space of 16
pages of 1024 words, each mapped into
a physical memory of 32 frames. Here is
how you calculate the various
parameters related to paging
 No: of bits needed for p = ceiling [log2
16] bits = 4
bits
 No: of bits needed for f = ceiling [log2 32]
bits = 5 bits
5050
 No : of bits needed for d = ceiling[log2 2048]
bits = 11 bits
Logical address size = |p| + |d| =4 + 11 =15
bits
Physical address size = |f| + |d|
= 5 + 11 = 16 bits
5151
CPUCPU
ff
pp dd ff dd
pp
LogicalLogical
addressaddress
PhysicalPhysical
addressaddress f0000…0000f0000…0000
f1111…1111f1111…1111
ff
Page tablePage table
MemoryMemory
5252
Segmentation is a process that breaks a
program into logical segments and allocates
the space for these segments in memory
separately. The segment can be of variable
length. They may not be contiguous memory.
The segments are more flexible. They are
visible for programmers. The programmer can
use them to tell the system to bring certain
data into memory always together.
5353
A segment table is maintained which
contain information about every segment
in a user program (process) . Each entry in
the segment table contains a base value
and a limit value . The base value contain
the actual physical address in memory
where the segment currently resides. The
limit value contain the size of the
segment .
5454
MainMain
memorymemory
limitlimit basebase
Segment tableSegment table
<< ++
S dS dCPUCPU
ss
yesyes
NoNo
5555

More Related Content

What's hot

What's hot (20)

Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-Basics
 
Unit II - 1 - Operating System Process
Unit II - 1 - Operating System ProcessUnit II - 1 - Operating System Process
Unit II - 1 - Operating System Process
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Operating Systems: Revision
Operating Systems: RevisionOperating Systems: Revision
Operating Systems: Revision
 
seminar report
seminar reportseminar report
seminar report
 
chapter 2 memory and process management
chapter 2 memory and process managementchapter 2 memory and process management
chapter 2 memory and process management
 
Operating System
Operating SystemOperating System
Operating System
 
Memory
MemoryMemory
Memory
 
Nachos 2
Nachos 2Nachos 2
Nachos 2
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Memory management
Memory managementMemory management
Memory management
 
Structure of processes ppt
Structure of processes pptStructure of processes ppt
Structure of processes ppt
 
cache
cachecache
cache
 
Process management
Process managementProcess management
Process management
 
Chapter 3: Processes
Chapter 3: ProcessesChapter 3: Processes
Chapter 3: Processes
 
3 process management
3 process management3 process management
3 process management
 
lotus domino questions answers 2017
lotus domino questions answers 2017lotus domino questions answers 2017
lotus domino questions answers 2017
 
OS_Ch4
OS_Ch4OS_Ch4
OS_Ch4
 
Chapter 3 - Processes
Chapter 3 - ProcessesChapter 3 - Processes
Chapter 3 - Processes
 
Understanding domino memory 2017
Understanding domino memory 2017Understanding domino memory 2017
Understanding domino memory 2017
 

Similar to Operating system ch#7

Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management Shashank Asthana
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : MemoryAmin Omi
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory managementrprajat007
 
Mca admissions in india
Mca admissions in indiaMca admissions in india
Mca admissions in indiaEdhole.com
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OSC.U
 
Lecture20-21-22.ppt
Lecture20-21-22.pptLecture20-21-22.ppt
Lecture20-21-22.pptssuserf67e3a
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptMohammad Almuiet
 
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationLM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationMani Deepak Choudhry
 
M20CA1030_391_2_Part2.pptx
M20CA1030_391_2_Part2.pptxM20CA1030_391_2_Part2.pptx
M20CA1030_391_2_Part2.pptxHarikishnaKNHk
 
Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029marangburu42
 
Mtech admission in india
Mtech admission in indiaMtech admission in india
Mtech admission in indiaEdhole.com
 

Similar to Operating system ch#7 (20)

Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : Memory
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Mca admissions in india
Mca admissions in indiaMca admissions in india
Mca admissions in india
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
 
Lecture20-21-22.ppt
Lecture20-21-22.pptLecture20-21-22.ppt
Lecture20-21-22.ppt
 
OS ppt.pdf
OS ppt.pdfOS ppt.pdf
OS ppt.pdf
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.ppt
 
UNIT-2 OS.pptx
UNIT-2 OS.pptxUNIT-2 OS.pptx
UNIT-2 OS.pptx
 
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationLM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
 
M20CA1030_391_2_Part2.pptx
M20CA1030_391_2_Part2.pptxM20CA1030_391_2_Part2.pptx
M20CA1030_391_2_Part2.pptx
 
Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029
 
Operating system
Operating systemOperating system
Operating system
 
Main memoryfinal
Main memoryfinalMain memoryfinal
Main memoryfinal
 
Dynamic loading
Dynamic loadingDynamic loading
Dynamic loading
 
VirutualMemory.docx
VirutualMemory.docxVirutualMemory.docx
VirutualMemory.docx
 
Mtech admission in india
Mtech admission in indiaMtech admission in india
Mtech admission in india
 
Os
OsOs
Os
 

Recently uploaded

Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Chameera Dedduwage
 
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )Pooja Nehwal
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝soniya singh
 
Presentation on Engagement in Book Clubs
Presentation on Engagement in Book ClubsPresentation on Engagement in Book Clubs
Presentation on Engagement in Book Clubssamaasim06
 
Mathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptxMathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptxMoumonDas2
 
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...Hasting Chen
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...henrik385807
 
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night EnjoyCall Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night EnjoyPooja Nehwal
 
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Kayode Fayemi
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Pooja Nehwal
 
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStrSaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStrsaastr
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Delhi Call girls
 
George Lever - eCommerce Day Chile 2024
George Lever -  eCommerce Day Chile 2024George Lever -  eCommerce Day Chile 2024
George Lever - eCommerce Day Chile 2024eCommerce Institute
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfhenrik385807
 
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptxMohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptxmohammadalnahdi22
 
ANCHORING SCRIPT FOR A CULTURAL EVENT.docx
ANCHORING SCRIPT FOR A CULTURAL EVENT.docxANCHORING SCRIPT FOR A CULTURAL EVENT.docx
ANCHORING SCRIPT FOR A CULTURAL EVENT.docxNikitaBankoti2
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Salam Al-Karadaghi
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfhenrik385807
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AITatiana Gurgel
 

Recently uploaded (20)

Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)
 
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
 
Presentation on Engagement in Book Clubs
Presentation on Engagement in Book ClubsPresentation on Engagement in Book Clubs
Presentation on Engagement in Book Clubs
 
Mathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptxMathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptx
 
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
 
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night EnjoyCall Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
 
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
 
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStrSaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
 
George Lever - eCommerce Day Chile 2024
George Lever -  eCommerce Day Chile 2024George Lever -  eCommerce Day Chile 2024
George Lever - eCommerce Day Chile 2024
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
 
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptxMohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptx
 
ANCHORING SCRIPT FOR A CULTURAL EVENT.docx
ANCHORING SCRIPT FOR A CULTURAL EVENT.docxANCHORING SCRIPT FOR A CULTURAL EVENT.docx
ANCHORING SCRIPT FOR A CULTURAL EVENT.docx
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
 
Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AI
 

Operating system ch#7

  • 1. 11
  • 2. Overview  Basic Requirements  Program Translation and address translation  Overlaying  Swapping  Contiguous memory allocation  Memory allocation methods 22
  • 3.  Logical vs. Physical Address Space  Paging  Segmentation 33
  • 4. 44
  • 5. Any mechanism and policy associated with memory management should satisfy certain requirements. These requirements are as follows:  Relocation  Protection  Sharing 55
  • 6.  The main memory is shared among different processes in multi programming.  It is not possible to know that where the program will be load in main memory when it is executed.  The processes are also swapped in and swapped out of main memory for maximum utilization of processor. 66
  • 7. The operating system need to know that the location of the process control information and execution stack. The process of converting the Logical address into Physical address is known as Relocation. 77
  • 8. In main memory many processes being executed at one time. Each process must be protected against unwanted interference by other processes. The program in other processes should not be able to reference the memory location in a process to read and write without permission. 88
  • 9. The memory protection must be relaxed in some cases. Some time several processes may be executing the same program such as an editor. The processes that cooperate to solve a problem may want to access shared data structures. 99
  • 10. The processes that will participate in the sharing must declare shared memory segments. The operating system is responsible for protecting the shared memory from unauthorized access by other processes. 1010
  • 11. A process has a logical address space. It is linear set of locations for program code, variable and, stack and etc. As the program executes, all parts of the logical address space is mapped to a physical address space. Physical address space is a subset of primary memory. 1111
  • 12. The address space is a product of the translation-linking-loading process. Different types of addresses are as follows:  Symbolic addresses  Logical addresses  Relative addresses  Physical addresses 1212
  • 13. An address generated by the CPU is commonly referred to as a Logical address where as an address seen by the memory unit-that is, the one loaded into the memory –address register of the memory is commonly referred to as the Physical address. the set of all logical address generated by a program from the Logical address space of the process . The set of all Physical addresses corresponding to these logical addresses is a physical address space of the process. 1313
  • 14. The total size of physical address space in a system is equal to the size of main memory. The run-time mapping from virtual to physical addresses is done by a piece of hardware in the CPU, called the memory management unit (MMU). 1414
  • 16. Translation of a source program in a high-level assembly language involves compilation and linking of a program. This process generates the machine language executable code (also known as binary image) for the give source program. To execute the binary code, it is loaded into the main memory and the CPU state is set appropriately. 1616
  • 17. The whole process is shown in the following diagram. Compile/Assemble Link Load Execute 1717
  • 18. The collection of processes that is waiting on the disk to be brought into the memory for execution forms the Input queue. In most cases a user program will go through several steps –some of which may be optional- before being executed. Address may be bound in different ways. 1818
  • 19. Address can be bound in instruction and data at different time, as discussed below briefly.  Compile time: if you know at compile where the process will reside in memory, the absolute addresses can be assigned to instructions and data by compiled.  Load time: if it is not know at compile time where the processes will reside in memory then the compiler must generate the re- locatable code. 1919
  • 20.  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 work. In case of compile and load time binding, a program may not be moved around in memory at run time. 2020
  • 21. Source program Other object modules Load module Object module Linkage editor Loader compiler or assembler Binary memory image loader Dynamically Loaded system binary Compile time Load time Execution timeDynamic linking 2121
  • 22. Overlaying is a technique that is used to execute a process even if the memory is not enough. The operating system can swap overlays and manage the memory. The overlays are useful when the program to be executed is larger then available memory. 2222
  • 24.  The earliest computing system required contiguous storage allocation in which each program occupied single contiguous memory block, the technique of multiprogramming was not possible. Main Memory Process a Operating system Figure of contiguous Memory Process b Process c 2424
  • 25.  In non-contiguous storage allocation a program is divided in several blocks that may be placed in different parts of main memory. It is difficult for operating system to control non-contiguous storage allocation. Main Memory Operating system Process a Process b Process c Figure of non contiguous Memory 2525
  • 26. A process cannot be executed in the CPU unless it is completely or partly in memory. A process not executed in CPU can be completely swapped out of memory to a backing store such as a high- speed disk. The swapping is done by swapper. Dispatcher tries to load a process into CPU and find that it is not currently in memory. It will call the swapper to swap the process back into memory. 2626
  • 27. Example P 2 User area Operating system Backing store Memory Swap out Swap in 2727
  • 28. The main memory must accommodate both operating system and the various user space. There are three schemes for memory allocation these are:  Single process allocation scheme  Fixed partition allocation scheme  Variable partition allocation scheme 2828
  • 29.  In this scheme only one process execute in memory at a time. The remaining part of the memory space will not be used. User process ………………… ………………… ………………… ………………… ………………… Unused Operating system Loaded from main storage Main Memory 2929
  • 30.  This scheme divided memory into a number of separate fixed areas. Each memory area could hold one process. …………… …………… Process c 300k …………… ………….. …………. Process b 200k …………..………….. Process a 150 Operating system Fixed partition Partition:3 400k Partition:2 300k Partition:1 200k …………. Unused space Memory 3030
  • 31.  The occurrence of wasted space in this way is called internal fragmentation.  It is called `Internal’ because it occurs within the space allocated to the process in question. Process b Process A ……………….. ……………….. Operating system ………………. ………...……. Internal fragmentation Example 3131
  • 32.  It is relatively simple to implementation.  It facilitates memory protection mechanism due to its fixed partitions.  The fixed partition sizes can prevent a process from being run due to the unavailability of a partition of sufficient size.  Internal fragmentation wastes space that collectively could accommodate another process. Advantages Disadvantages 3232
  • 33.  It allocate the exact amount of memory to the process as required. …………………………. …Available space …………………………. Operating system Process A Process B Process C Exact required Size allocation 3333
  • 34.  If a new process D is loaded then it is allocated adjacent to process C if available space is sufficient.  When a process terminates, the space it occupies is freed and become available for the loading of a new process. ..……………………… Operating system Process A Process B Process C Process D New process Loaded from storage 3434
  • 35. As processes come and go ,holes of free space is created in the main memory. Distribution of free memory to processes is called External fragmentation. External fragmentation refers to the situation when free memory space exists to load a process in the memory but the space is not contiguous. 3535
  • 37. A process that is adjacent to one or more holes may terminate and free its space allocation. The holes can be viewed and utilized as a single hole. This effect is called Coalescing holes. In variable partition the system must keep track of the position and size of each hole. 3737
  • 38.  In this situation linked list is a helper key.  A common method is use a linked list.  A linked list contains pointers to the start of each hole and the hole size. size Process A Process C size NIL Free holes Linked List :::::::::::::::::::::::: :::::::::::::::::::::::: :::::::::::::::::::::::: :::::::::::::::::::::::: Operating system 3838
  • 39. The fragmentation problem encountered in the previous method the can be resolved by physically moving the processes about the memory in order to close up the holes. It bring the free space into a single large block. This method is called compaction. 3939
  • 40. Example Process A Process C Process C Process A Operating system Operating system ordered Memory before compaction Memory after compaction 4040
  • 41.  A process must be unloaded from memory if its CPU time-slice has ended. It is placed in the ready queue to be loaded again later. It allows the memory space for another process to be loaded. A process can change place in memory for the following three main reasons: 4141
  • 42.  A process must be unload from memory if it enters block state by calling I/O function etc. then it is placed in the block queue to be loaded later.  The process may change its position if compaction is applied. It must be possible for a process to be loaded at any address selected by the operating system. 4242
  • 43.  The Limit register is used to hold the highest memory location that a process can access. By this way, each process is protected from other processes in memory.  A Logical address is expressed as a location relative to the beginning of the process. Instructions in the program contain only logical address. 4343
  • 44.  A Physical address is an actual location in main memory. When a process is loaded in memory, the physical address of the first location is put in the base register. All processes are interpreted as a being relative to this base address. 4444
  • 45. a Physical address Limit bProgram address Base Register Limit Register b + a 4545
  • 46. Physical memory is divided into fixed-size blocks called frames. Logical memory is also divided into the same size blocks called pages. A single process may require many pages of memory. When a process is scheduled for execution, its pages are loaded into any available memory frames from the backing store. 4646
  • 47. The backing store is also divided into blocks. The blocks are the same size as the frames in main memory. Paging requires additional hardware support in the form of a page table. 4747
  • 48. Every logical address generated by the CPU consist of two parts:  A Page Number (p)  A page displacement offset (d) The page table consist the frame number (f) of each page in physical memory. The frame number is combined with the page offset to obtain the physical memory address of memory location and object address by the corresponding logical address. 4848
  • 49.  P is use to index the process page table; page table entry contains the frame number ,f, where page p is load.  The physical address of the location referenced by (p , d) is computed by appending d at the end of f as shown below: ff dd 4949
  • 50. Assume a logical address space of 16 pages of 1024 words, each mapped into a physical memory of 32 frames. Here is how you calculate the various parameters related to paging  No: of bits needed for p = ceiling [log2 16] bits = 4 bits  No: of bits needed for f = ceiling [log2 32] bits = 5 bits 5050
  • 51.  No : of bits needed for d = ceiling[log2 2048] bits = 11 bits Logical address size = |p| + |d| =4 + 11 =15 bits Physical address size = |f| + |d| = 5 + 11 = 16 bits 5151
  • 52. CPUCPU ff pp dd ff dd pp LogicalLogical addressaddress PhysicalPhysical addressaddress f0000…0000f0000…0000 f1111…1111f1111…1111 ff Page tablePage table MemoryMemory 5252
  • 53. Segmentation is a process that breaks a program into logical segments and allocates the space for these segments in memory separately. The segment can be of variable length. They may not be contiguous memory. The segments are more flexible. They are visible for programmers. The programmer can use them to tell the system to bring certain data into memory always together. 5353
  • 54. A segment table is maintained which contain information about every segment in a user program (process) . Each entry in the segment table contains a base value and a limit value . The base value contain the actual physical address in memory where the segment currently resides. The limit value contain the size of the segment . 5454
  • 55. MainMain memorymemory limitlimit basebase Segment tableSegment table << ++ S dS dCPUCPU ss yesyes NoNo 5555