Feature #1: Allocate Space
Explore how to allocate memory space for new processes by identifying contiguous subsets of running processes that sum to a required size. Learn to calculate cumulative sums and use hashmaps to count subarrays meeting size criteria, improving your understanding of memory management in operating systems.
We'll cover the following...
Description
The first feature we need to build will identify the contiguous sub-processes that can be replaced with an incoming process of size n. In this scenario, we have p running processes numbered 1 through p in our system. We allocate memory to these processes contiguously such that process 1 occupies p_1 MB, process 2 immediately occupies p_2 MB, and so on. We receive the contiguous allocations p_1, p_2, …, p_n as an array. An incoming process requires a contiguous chunk of n MB anywhere in memory. To allocate memory to this process, we can evict one process or a set of processes that occupy contiguous memory locations that once evicted free up an n MB amount of space collectively. Here, our task will be to find the total number of all possible subsets of currently running processes that together account for a contiguous allocation of n MBs of memory.
In this scenario, we will be provided with two inputs. First, we will be given a list of integers representing the size of contiguous memory chunks allocated to ...