IN C PROGRAMMING CODE ONLY!
1. segmentation: p3_test1.txt
2. paging: p3_test2.txt
The goal of this project is to write a simple memory management simulator based on the topics covered in class. You must write a memory manager that supports both segmentation and paged memory allocation. For simplicity, assume that processes do not grow or shrink, and that no compaction is performed by the memory manager.
Segmentation: Write a segmentation based allocator which allocates three segments for each process: text, data, and heap. The memory region within each segment must be contiguous, but the three segments do not need to be placed contiguously. Instead, you should use either a best fit, first fit, or worst fit memory allocation policy to find a free region for each segment. The policy choice is yours, but you must explain why you picked that policy in your README. When a segment is allocated within a hole, if the remaining space is less than 16 bytes then the segment should be allocated the full hole. This will cause some internal fragmentation but prevents the memory allocator from having to track very small holes. You should consider the following issues while designing your memory manager:
Efficiency of your search algorithms: First-fit, worst-fit, and best-fit all require you to search for an appropriate hole to accommodate the new process. You should pay careful attention to your data structures and search algorithms. For instance, keeping the list of holes sorted by size and using binary search to search for a hole might improve efficiency of your best-fit algorithms. We do not require you to use a specific algorithm/data structure to implement the selected policy; you have the flexibility of using any search algorithm/data structure that is efficient. We'll give you 10 points for any design that is more efficient than a brute-force linear search through an unsorted list of holes. Similarly, use an efficient search algorithm when deallocating a process from the processList. Explain all design decisions, the data structures and search algorithms used clearly in the README file.
Free block coalescing: When a process terminates, the memory allocated to that process is returned to the list of holes. You should take care to combine (coalesce) holes that are adjacent to each other and form a larger contiguous hole. This will reduce the degree of fragmentation incurred by your memory manager.
Paging: Next write a paging based memory allocator. This should split the system memory into a set of fixed size 32 byte pages, and then allocate pages to each process based on the amount of memory it needs. Paging does not require free block coalescing, but you should explain in your README your choice of algorithm and data structure for tracking free pages.
Sample Outputs:
Data Structures:
Both of your memory managers should maintain a processList that lists all currently active processes, the process Id and size of each process. For the segmentation allocator, you should also track the start location of each segment. For the paging allocator you must track what physical page is mapped to each virtual page within the process, as well as the number of bytes used in each page.
You are free to use any data structures (arrays, linked list, doubly linked list, etc) to implement these lists, but you should explain why you pick the data structure you choose. This decision will also affect the use of search algorithms in the segmentation allocator.
Input File:
You program should take input from a file and perform actions specified in the file, while printing out the result of each action. The format of the input file is as follows:
An actual file may look as follows
IN C PROGRAMMING CODE ONLY! 1. segmentation: p3_test1.txt 2. paging: p3_test2.txt The goal of this project is to w
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am