3,016 views
1 votes
1 votes
Most systems allow a program to allocate more memory to its address space during execution. Allocation of data in the heap segments of programs is an example of such allocated memory. What is required to support dynamic memory allocation in the following schemes ?

$a$. Contiguous memory allocation
$b$. Pure segmentation
$c$. Pure paging

2 Answers

2 votes
2 votes
  • Contiguous memory allocation may require relocation of the whole program when there is not enough space in the allocated memory space.
  • Pure segmentation also may require relocation of the segment if the segment cannot grow in the allocated memory space.
  • Pure paging is the best scheme in this case as allocation of pages(non-contiguous) is possible without relocation.
0 votes
0 votes
To support dynamic memory allocation in different memory allocation schemes, the following requirements are necessary:

a. Contiguous Memory Allocation:
In contiguous memory allocation, memory is divided into fixed-size partitions, and each partition is allocated to a process. To support dynamic memory allocation in this scheme, the following requirements are needed:

1. Memory Management Unit (MMU): An MMU is required to translate logical addresses to physical addresses and perform memory protection.

2. Memory Allocation/Deallocation Mechanism: A mechanism is needed to allocate and deallocate memory dynamically. This mechanism should keep track of free and allocated memory blocks and efficiently manage the allocation and deallocation requests.

3. Memory Fragmentation Handling: Contiguous memory allocation can lead to two types of fragmentation: external fragmentation and internal fragmentation. Techniques such as compaction and relocation may be employed to reduce fragmentation.

b. Pure Segmentation:
In pure segmentation, the logical address space of a process is divided into variable-sized segments, each representing a different unit of the program (e.g., code segment, data segment). To support dynamic memory allocation in pure segmentation, the following requirements are necessary:

1. Segmentation Table: A segmentation table is required to store the base address and length of each segment for a process. This table is used to translate logical addresses to physical addresses.

2. Segmentation Mechanism: A mechanism is needed to allocate and deallocate segments dynamically. This mechanism should manage the segmentation table and ensure that segments are appropriately allocated and deallocated.

3. Memory Protection: As different segments may have different access permissions, memory protection mechanisms are required to enforce access control and prevent unauthorized access to segments.

c. Pure Paging:
In pure paging, the logical address space of a process is divided into fixed-sized pages, and physical memory is divided into fixed-sized frames. To support dynamic memory allocation in pure paging, the following requirements are necessary:

1. Page Table: A page table is required to store the mapping between logical pages and physical frames. Each entry in the page table contains the frame number corresponding to a logical page.

2. Page Replacement Algorithm: In case the physical memory is full and a new page needs to be allocated, a page replacement algorithm is needed to select a page to be evicted from the memory. Common page replacement algorithms include LRU (Least Recently Used), FIFO (First-In-First-Out), and Optimal.

3. Memory Management Unit (MMU): An MMU is required to translate logical addresses to physical addresses using the page table.

4. Memory Allocation/Deallocation Mechanism: A mechanism is needed to allocate and deallocate pages dynamically. This mechanism should manage the page table, allocate available pages to processes, and handle page faults during memory access.

Note: It's important to mention that there are also hybrid memory allocation schemes that combine aspects of contiguous allocation, segmentation, and paging to address the limitations of individual schemes. These hybrid schemes aim to provide more flexibility, efficiency, and scalability in memory management.

Related questions

0 votes
0 votes
0 answers
1
akash.dinkar12 asked Mar 21, 2019
286 views
On a system with paging, a process cannot access memory that it does not own. Why ? How could the operating system allow access to other memory ? Why should it or should ...
0 votes
0 votes
0 answers
2