Download presentation
Presentation is loading. Please wait.
1
Module IV Memory Organization
2
Contiguous Memory Allocation
In contiguous memory allocation, the memory is divided into two partitions: one for OS and other for user processes.
3
Contiguous Memory Allocation
Advantages It is simple. It is easy to understand and use. Disadvantages It leads to poor utilization of processor and memory. Users job is limited to the size of available memory.
4
Partitioning It involves splitting of memory into sections to allocate processes including operating system. There are two schemes for partitioning: Fixed size partitions Variable size partitions
5
Fixed Size Partitions The memory is partitioned to fixed size partition. They are of two types : Fixed Equal-size Partitions Fixed Variable Size Partitions
6
Fixed Equal-size Partitions
It divides the main memory into equal number of fixed sized partitions OS occupies some fixed portion and remaining portion is for user processes.
7
Fixed Equal-size Partitions
Advantages Any process whose size is ≤ partition size can be loaded into any available partition. It supports multiprogramming. Disadvantages If a program is too big to fit into a partition, overlay technique is used Memory use is inefficient if block of data to be loaded is small. (If a partition is of 1M,remaining 7M cannot be used) It is known as Internal Fragmentation.
8
Fixed Variable Size Partitions
By using fixed variable size partitions, we can overcome some of the disadvantages present in fixed equal size partitioning.
9
Fixed Variable Size Partitions
Disadvantage There is a problem of wastage of memory. For example, a process that requires 4MB of memory would be placed in the 5MB partition which is the smallest available partition. In this partition, only 4MB is used, the remaining 1MB cannot be used by any other process, so it is wastage.
10
Fixed-sized Partitions
Degree of multiprogramming is bound by the number of partitions. When a partition is free, a process is selected from input queue and is loaded into it. When the process terminates, the partition becomes available.
11
Dynamic Partitioning In this method, the partitions are of variable length and number. When a process is brought into main memory, it is allocated exactly as much memory as it requires and no more. Initially it seems that there will be only one hole at the end, so the waste is less. But as swap- out and swap-in occurs, then more and more hole will be created, which will lead to more wastage of memory.
12
Dynamic Partitioning Consider a main memory of 2MB out of which 512KB is used by the Operating System.
13
Dynamic Partitioning Consider 3 processes of size 425KB, 368KB and 470-KB loaded into the memory. This leaves a hole at end, which is too small for a 4th process.
14
Dynamic Partitioning The fourth process is of 320KB and OS swaps out process2, which leaves sufficient room for new process. Since process-4 is smaller than process-2, another hole is created
15
Dynamic Partitioning Later when process 2 is ready, process-1 is swapped out and process-2 is swapped in there. It will create another hole. In this way lot of small holes is created which leads to memory wastage.
16
Dynamic Partitioning When a process is allocated space, it is loaded into memory When a process terminates, it releases its memory to fill it with another process from the input queue. The new hole could be used for a new processes which leads to dynamic storage allocation The commonly used solutions are the first-fit, best-fit, and worst-fit strategies
17
Memory Allocation Policies
First fit. Allocate the first hole that is big enough. Start searching at the beginning of the set of holes or at the location where the previous search ended. Stop searching as a large enough free hole is found Best fit. Allocate the smallest hole that is big enough. Search the entire list, unless the list is ordered by size. This strategy produces the smallest leftover hole.
18
Memory Allocation Policies
Worst fit. Allocate the largest hole. Again, we must search the entire list, unless it is sorted by size. This strategy produces the largest leftover hole
19
First Fit Algorithm
35
First Fit Algorithm The Internal fragmentation is 35K
36
Best Fit Algorithm
56
Best Fit Algorithm The Internal fragmentation is 30K
57
Worst Fit Algorithm
76
Problem Given memory partitions of 100K, 500K, 200K, 300K and 600K (in order), how would each of first fit, best fit and worst fit algorithms place processes of 212K , 417K , 112K and 426K
77
Solution : First Fit 100K 500K 200K 300K 600K 212K 112K 417K
426K cannot be kept in any partition
78
Solution : Best Fit 100K 500K 200K 300K 600K 417K 112K 212K 426K
79
Solution : Worst Fit 100K 500K 200K 300K 600K 417K 112K 212K
426K cannot be kept in any partition
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.