L-5.8: Need of Paging | Memory Management | Operating System
Summary
TLDRThis video script delves into non-contiguous memory allocation, a method where memory is allocated to processes in a non-consecutive manner. It contrasts this with contiguous allocation, highlighting how non-contiguous allocation can combat external fragmentation by dividing processes into fixed-size partitions called pages, which are then placed in frames of the main memory. The script explains the dynamic nature of memory allocation, emphasizing the efficiency of paging in utilizing memory and eliminating fragmentation.
Takeaways
- 🧩 Non-contiguous memory allocation allows processes to be divided and placed in different locations in RAM, unlike contiguous allocation which requires processes to be placed in consecutive memory locations.
- 🔄 This method helps in reducing external fragmentation, a problem where memory is divided into many small blocks that cannot be used efficiently.
- 💡 The script introduces the concept of 'paging' as a solution to external fragmentation, where memory is divided into fixed-size partitions called 'pages' and 'frames'.
- 📏 The size of a page is made equal to the size of a frame to ensure that each page fits perfectly into a frame, optimizing memory usage.
- 🚀 The process of dividing a process into pages is done in secondary memory before it is loaded into the main memory, which is a time-saving approach.
- 🔄 Dynamic hole creation in RAM is a challenge because the availability and size of these holes change as processes are loaded and unloaded.
- 📚 The script uses an 8KB RAM example with 1KB frames to illustrate how processes can be divided into pages and allocated to frames in a non-contiguous manner.
- 🔄 When a process is completely removed, the frames it occupied become available as holes, which can then be used to accommodate new processes or parts of processes.
- 📝 The script emphasizes that the non-contiguous allocation method can lead to a more efficient use of memory by fitting pages into available frames, thus reducing wasted space.
- 🔑 The paging concept is crucial for modern operating systems as it allows for efficient memory management and helps to eliminate the issues associated with external fragmentation.
Q & A
What is non-contiguous memory allocation?
-Non-contiguous memory allocation is a method where memory is allocated to different processes in a non-consecutive manner. It allows a process to be divided and placed in separate locations within the RAM.
How does non-contiguous memory allocation help with external fragmentation?
-Non-contiguous memory allocation helps reduce external fragmentation by allowing processes to be divided and placed in different memory locations, thus utilizing the available memory more efficiently without leaving gaps between allocated memory blocks.
What is the main difference between contiguous and non-contiguous memory allocation?
-In contiguous memory allocation, a process must fit entirely within a single, contiguous block of memory. In contrast, non-contiguous memory allocation allows a process to be divided and placed in separate, non-adjacent blocks of memory.
What is the concept of 'holes' in the context of memory allocation?
-In the context of memory allocation, 'holes' refer to the unused or free memory spaces within the RAM. These holes can be of varying sizes and are dynamically created and changed as processes are loaded and unloaded from memory.
Why is dividing a process into partitions considered costly in non-contiguous memory allocation?
-Dividing a process into partitions is considered costly because it requires analyzing the available memory holes at runtime, determining their sizes, and then dividing the process accordingly. This process is time-consuming and can lead to inefficiencies in memory management.
What is the term used for the partitions created during non-contiguous memory allocation?
-The term used for the partitions created during non-contiguous memory allocation is 'pages'. These pages are the portions of a process that can be independently allocated to different memory frames.
What is a 'frame' in the context of memory management?
-A 'frame' refers to a fixed-size partition of the main memory in a computer system. In the context of memory management, frames are the slots in RAM where pages from a process can be placed.
Why is it important that the size of a page is equal to the size of a frame?
-It is important that the size of a page is equal to the size of a frame to ensure that each page fits perfectly into a frame without wasting any space, thus maximizing memory utilization and minimizing fragmentation.
How does the concept of paging help in managing memory more efficiently?
-Paging helps in managing memory more efficiently by dividing processes into fixed-size pages that can be independently allocated to frames in the main memory. This method reduces external fragmentation and allows for more flexible memory allocation strategies.
What is the advantage of using non-contiguous memory allocation with paging?
-The advantage of using non-contiguous memory allocation with paging is that it eliminates external fragmentation by allowing pages to be distributed across different frames in the main memory, regardless of their order or the size of the available holes.
Outlines
🧩 Introduction to Non-Contiguous Memory Allocation
This paragraph introduces the concept of non-contiguous memory allocation, explaining how memory can be allocated in different locations within the RAM. Unlike contiguous memory allocation, where a process must fit entirely in a single continuous block, non-contiguous memory allocation allows a process to be divided into smaller parts that can occupy separate locations. This method helps in utilizing available memory more efficiently by placing divided parts of a process into different holes or spaces in the memory. The example provided illustrates how a 6KB process can be divided into three 2KB partitions, each fitting into separate 2KB holes in the memory. This approach contrasts with contiguous allocation, which requires a single 6KB block for the process, highlighting the main benefit of non-contiguous allocation: the ability to use smaller, fragmented spaces effectively.
🔄 Challenges and Solutions in Non-Contiguous Memory Allocation
This paragraph discusses the dynamic nature of non-contiguous memory allocation and the challenges it presents, particularly the frequent creation and changing of memory holes during runtime. The holes vary in size and number, making the division of processes into partitions a complex and time-consuming task. The paragraph also emphasizes the inefficiency of dynamically dividing processes at runtime, proposing a more efficient method: pre-dividing processes into pages before they are loaded into the main memory. This method involves pre-partitioning both the processes and the main memory into pages and frames, respectively, with each page fitting precisely into a frame. The terms 'page' and 'frame' are introduced, defining the smallest units of a process and memory partitioning. By ensuring that the size of a page matches the size of a frame, the system can manage memory allocation more effectively, reducing the time and computational resources required during runtime.
📚 Practical Example of Paging and Its Advantages
The final paragraph provides a practical example to illustrate the concept of paging in non-contiguous memory allocation. It describes a scenario where an 8KB RAM is divided into eight 1KB frames, matching the page size of the incoming processes. The example demonstrates how processes of various sizes (2KB each) can be divided into pages and allocated to different frames in RAM. It shows that while non-contiguous memory allocation allows flexibility in placing these pages in any available frames, if contiguous memory were required, the process would fail due to fragmented space. The advantage of using non-contiguous allocation through paging is highlighted: it effectively eliminates external fragmentation by ensuring that each page can occupy any available frame, regardless of their location. This method ensures efficient memory utilization and simplifies the memory management process, supporting the need for and the benefit of implementing paging in memory allocation strategies.
Mindmap
Keywords
💡Non-contiguous memory allocation
💡External fragmentation
💡Process
💡RAM
💡Partition
💡Paging
💡Frame
💡Dynamic allocation
💡Memory hole
💡Contiguous memory allocation
💡Memory management
Highlights
Introduction to non-contiguous memory allocation and its contrast with contiguous allocation.
Explanation of how processes can be expanded in non-contiguous allocation by being placed in different RAM locations.
Illustration of the concept using three 2KB memory holes and a 6KB process example.
Clarification that in non-contiguous allocation, a process can be divided and allocated across separate memory partitions.
Discussion on the limitations of contiguous memory allocation and the emergence of external fragmentation.
Proposed solution to external fragmentation through non-contiguous memory allocation.
Description of the dynamic creation of memory holes and the challenges it poses for process allocation.
The costly method of dividing processes based on the size and availability of memory holes.
The method of pre-dividing processes into pages before they arrive in the main memory.
Definition and importance of the term 'page' in the context of memory allocation.
Definition and importance of the term 'frame' in the context of main memory partitioning.
The critical point that the size of the page must always be equal to the size of the frame for efficient memory use.
Advantages of pre-allocating memory to pages in a non-contiguous manner to eliminate external fragmentation.
Example of how a 8KB RAM with 1KB frame size can be utilized for process allocation.
Demonstration of process allocation in RAM with the creation of holes and the subsequent allocation of a new process.
The concept of paging, dividing processes into pages of equal size to the frame before memory allocation.
The advantage of paging in fitting process pages properly into frames, thus improving memory efficiency.
Conclusion on the necessity of paging to remove external fragmentation and improve memory allocation.
Transcripts
Hello guys the topic is non-contiguous memory allocation
in non-contiguous memory allocation
we are allocating the memory to the different different processes
in a non-consecutive manner
in non-contiguous memory allocation
a process cannot span between the two different locations
but here a process can be expand
means after dividing one process can put in different different locations in RAM
this is the concept
now let's say in main memory there are these three holes
of 2KB 2KB and 2KB
if the process size is
let's say a process came, P1 and the process size is 6KB
now this 6KB process
can not be put according to the contiguous memory allocation
because, the rule in contiguous memory allocation is that
that if one process will come then i will completely fit there
we can not divide and put different locations
but in non-contiguous memory allocation what we are doing..
this process can be divided and it can be put on different different locations
what i mean to say is
to this 6KB process,
by dividing in three partitions
means we make three partitions of 2KB each
and then
first partition I put here
second partition I put here
and third one I put here,
it can be done in non-contiguous memory allocation
but it can not be done in contiguous memory allocation
where a process can not be divided and placed in different different locations
due to that what the problem was arising external fragmentation
then how can we remove external fragmentation
the method is non-contiguous memory allocation
what are we doing there
are dividing one process and putting different different locations in memory
so we are trying to remove external fragmentation
and definitely external fragmentation is getting removed
but the point is when this process came
when this process started to come in RAM
means when it knocked in RAM at that time
here i am checking how many holes are empty at what time
and what is the size of those holes
and i am dividing those process according to the size of holes
A very important point is there
I'm dividing the processes over here
I'm doing the processes
But this division is a very costly method
While it is costly
When this process has come to memory
or is just about to come to the main memory
What I'm doing at the same time
according to the memory and according to these holes
I am dividing the process
What is the problem arising over here
These holes are created dynamically
Means these keep on changing on runtime
It can also happen that you put this process here
You have put one partition here and one partition here, and one partition here
Further it can be possible
It can be possible like
If this partition is empty now
If partition over here..
sorry, If the process was there and this process has gone out
What I meant to say is this space has become hole now
and this has been occupied the process
This also has been occupied by the process
And this too is occupied by the process
We have made P1 occupy this
we have put P 1 in these three locations
And I have put by dividing into 2KB 2KB 2KB
Now this available empty space
And the available size of this space is 1KB and 1KB
1KB and 1KB
these two holes of 1 KB are created
now when these two holes of 1 KB are created 1 and 1KB
now if one process comes
let's say one more process came, P2
and the size of process is 2KB
can i put this 2KB here, no i can not put according the contiguous
so according to the non contiguous i can put, but what will happen
what will happen here, when this process is knocking here
that i want to come in the RAM
so at that time i am checking that how many holes are there, there are two holes
and what is the size of these two holes 1KB 1KB
then i will decide that the size of my process is 2KB
I will decide this in 2 parts
so size of first partition is 1 KB and second also 1 KB
so I will put this 1KB here and this 1KB here
but the problem is
these holes are creating dynamically and these are changing every time
Their size is changing and their number is changing
Whenever the process will try to come in the RAM
At that time by analyzing those holes, their numbers and their size
you will be dividing the process
And this is a very time consuming process
In doing this thing your a lot of time might be wasted
So here
What method we are following in the non contiguous
Method is same that we have a process
Whenever the process will come we will divide it, but what are we changing here
Whatever the process we have
We will divide that process beforehand
We will divide that process beforehand means before arrival of this in main memory
Its division will complete, means its partition will complete
so this process when i will divide in partitions
So then what do I call this one partition page
This is called the page
And where am I doing this partition in the secondary memory
When I read this process in the secondary memory
at that time only I divided it in pages
And what did other side
The RAM we had the main memory we had
We have divided main memory beforehand
And in technical terms we call every partition and every slot of main memory..
frame
Yes that is called the frame
So what method we are following here , we are following the same method
But when the process will come in the RAM
We are not doing divisions at that time
We are already dividing processes in the secondary memory
And what do we call each of these partition pages
Means every process will be divided in the pages
And what we will do in RAM also, in main memory also
We will do partitions before itself
And what do we call every partition and every slot ... frame
So actually what are you doing here
Important point is, the size of the page
will always be equal to the size of the frame
This is very very important point
This point is will be used in all of the paging
that the size of the page will be equal to the size of the frame
reason being is obviously this page
The process which we are dividing in the page
Where will this partition go and sit
This will go and sit in this frame.. ..this will go and sit there in that frame
If it goes there then it should fit properly
So to make it fit properly, so that I can use memory more efficiently
What will I do, whatever the size will be of this page that will be the size
of this frame also
So that this frame can put one page easily
Alternatively we can also say that this page should be fit in one frame
So what we will have to do for that beforehand itself
whatever the size of the pages is that should be the size of that frame also
Or I can also say that whatever the size of the frame is according to that only
We'll divide processes in the pages
So I will already do this work
So that when this process will come
When the page of this process will come
I will put this page here
Next page comes i will put here
If this slot is busy then I will put the third page here
If this slot is busy then I will put 4th page here
And let's say 5th page I'll put here
So now means we can allocate the memory to these pages
in a non contiguous memory
It is not necessary that did these page should be continuous
These can be distributed in the different different locations
So what is the advantage I'm getting over here
External fragmentation is totally removed from here
Let's try to analyze it with the very simple example
Let's say I'm having the RAM of 8KB
I have RAM of 8KB
and the page size or frame which i have fixed
Frame size is 1KB
so if the size of the RAM is 8 KB and the size of one frame is 1 KB
Then how many number of frames will be there,
there will be total 8 number of frames
So we are drawing here 8 number of frames
So zero one two three four five
six and seven
So 8 number of frames will be there
Now say if the process comes
let's say a process came P1
And the size of P1 process is 2KB
size of P1 process is 2KB
Then I will also have to divide this process in pages
And what is the size of the page,
whatever is size of the frame is the size of the page
So what will be the size of page also 1KB
So page size is equal to frame size is equal to 1KB
So now if the size of the process is 1 KB then I will make 2 partitions of 1 KB each
Let's say one more process came let's say P2
so i will write here P2 also
Let's say if that is also of 2 KB, then I can make two partitions of P2 also
so in the same manner P3 is also coming
will make 2 partitions of P3 also, and if P4 comes,
then will make 2 partitions fo P4 also
if all those four processes are 2 KB each
If already it is 2KB 2KB
Now simply what we can do we can allocate the partition of P1 here
Now if these slots are empty
If initially these slots are empty,
then it's not necessary that you have to follow non contiguous
means you put these to different different locations, if these slots are empty
Then you can put them directly also
And yes if slots are not empty then you will put them separately only
Normally non contiguous doesn't mean it is not contiguous
yes If the slots are empty then you put P1 here
Second slot of P1 put here
similarly we have put the 1st page of P2 here and second page of P2 here
first page of P3 process here and second page of P3 process here
first page of P4 process here and second page of P4 process here
we have given all these pages
i have put these 2 pages here, these 2 pages here
these 2 pages here, these 2 pages here
So simply we have allocated the memory to the pages
Now the point is
if at a point
let's say P2 has gone out from here
P2's work is executed here
Whatever the instructions were there in the P2 are executed
Similarly P4 instructions are also executed here
So P1 and P2 has gone out
So in a way what we can say is, here these 2 holes are created
and here these 2 holes are created
Size of these two holes and the size of all these holes are 1KB 1KB 1KB 1KB
means total I have 4 KB of space
So if at this time a process comes P5
and the size of P5 is 4KB
So what will I do, first I will divide the process of 4KB in pages
How many pages are created 4 pages
So if it were a contiguous
how much space do I have, 4KB
And process is 4KB, so I cannot allocate
because it is not continuous
But in non contiguous we can easily distribute it
How?, I will put 2 pages of P5 here
and the remaining 2 pages of P5 will put here
So means with the help of paging, this is called the concept of paging
So what do we do in paging, we divide processes in pages beforehand
And what will be the size of every page
it will be equal to the frame size of main memory
So what advantage i have
The page of processes will properly fit in the frame
Or the frame will properly carry a page
And then simply we will allocate memory to the pages
So easily we have removed the external fragmentation
So this is the first advantage and This is why we need the paging
So This is all about why we need the paging concept
Thank You
Weitere ähnliche Videos ansehen
L-5.3: Internal Fragmentation | Fixed size Partitioning | Memory management | Operating System
L-5.2: Memory management Techniques | Contiguous and non-Contiguous | Operating System
L-5.4: Variable size Partitioning | Memory management | Operating System
Operating Systems 2 - Memory Manager
L-5.5: First Fit, Next Fit, Best Fit, Worst fit Memory Allocation | Memory Management | OS
Basics of Dynamic Memory Allocation
5.0 / 5 (0 votes)