Fragmentation
In operating systems, fragmentation refers to the phenomenon where memory or disk space is allocated inefficiently, resulting in wasted space. There are two types of fragmentation: external fragmentation and internal fragmentation.
External Fragmentation
External fragmentation occurs when there is enough total memory space to satisfy a request, but it is not contiguous. This happens when there are many small gaps in memory, resulting in the inability to allocate larger memory segments. This can lead to a significant decrease in system performance, as memory allocation requests take longer to process.
Internal Fragmentation
Internal fragmentation, on the other hand, occurs when memory is allocated in fixed-size blocks, and the size of the allocated block is larger than the actual size of the data being stored. This results in wasted memory space, as the unused portion of the allocated block cannot be used by any other process.
Differences Between Internal Fragmentation and External Fragmentation:
Internal Fragmentation | External Fragmentation |
---|---|
Memory is allocated in fixed-size blocks | Free memory is not contiguous |
Allocated memory blocks are larger than needed | Free memory is fragmented into smaller blocks |
Occurs when memory blocks are not fully utilized | Occurs when there are many small gaps of free memory |
Results in waste of memory resources | Results in inability to allocate memory |
Can be addressed by using variable-size allocation schemes, such as segmentation | Can be addressed by using dynamic memory allocation techniques, such as compaction |
Mostly occurs in systems that use fixed-size allocation schemes, such as static memory allocation | Mostly occurs in systems that use dynamic memory allocation schemes, such as heap allocation |
Solving Fragmentation Problem Using Paging
To solve the problem of fragmentation, operating systems use various techniques, one of which is paging. Paging is a memory management technique used by operating systems to handle virtual memory. The main idea behind paging is to divide physical memory into small fixed-size blocks called pages and divide the logical memory into small fixed-size blocks called frames.
When a process requests memory, the operating system allocates one or more pages to the process. The pages are assigned to frames in physical memory, and the process can access them through the page table. The page table maps the logical memory addresses to the physical memory addresses.
Paging solves the fragmentation problem by allocating memory in fixed-size pages, eliminating external fragmentation. Internal fragmentation is also reduced since the pages are allocated only in the required size. This results in efficient memory utilization and improves system performance.
Paging also offers other benefits, such as improved memory protection and sharing. The page table can be used to protect memory from unauthorized access and to share memory between multiple processes. Paging also allows the operating system to swap pages to disk, freeing up physical memory for other processes.
OS-2022
Q-1.
(a) Write are the functions of operating systems? write a note on multi programmed operating systems ?
(b) Distinguish between client server and peer to peer model of distributed systems .
Q-2.
(b) What is meant by Storage Structure? Discuss Storage Hierarchy.
Q-3.
(a) What are the criteria for evaluating the CPU scheduling algorithms? Why do we need it?
Q-4.
(a) What is synchronization? Explain how semaphores can be used to deal with n-process critical problem.
Q-5.
Q-6.
(b) What are the disadvantages of single contiguous memory allocation? Explain.
Q-7.
(a) Briefly explain about single-level, two-level and three Structured directories.
(b) What is disk scheduling? Explain the C-SCAN scheduling by giving an example.
Q-8.
(b) UNIX file system.
(c) Program and system threats.