Skip to main content

The Objective Of This Weeks Lab Is To Simulate And Evaluate

Page 1

The Objective Of This Weeks Lab Is To Simulate And Evaluate Different The objective of this week's lab is to simulate and evaluate different memory allocation and deallocation techniques—specifically first fit, next fit, best fit, and worst fit—when a linked list is used to track memory usage. In this simulation, a Memory component will be implemented for two of these four techniques, to be completed over two weeks. The first technique is due in Week 4, and the second in Week 5. The simulated memory size is 256 KB, partitioned into units of 2 KB each, totaling 128 memory units. Each process can request between 3 and 10 units of memory. The simulation comprises three main components: a Memory component for managing memory with a specific allocation technique, a request generation component that creates allocation and deallocation requests, and a statistics reporting component that outputs relevant metrics. The Memory component must provide the following functions: int allocate_mem(int process_id, int num_units): Allocates memory units to the process identified by process_id. Returns the number of nodes traversed in the linked list if successful; otherwise, returns -1. int deallocate_mem(int process_id): Deallocates all memory allocated to the process with the specified process_id. Returns 1 if successful. int fragment_count(): Returns the number of holes (fragments) of sizes 1 or 2 units currently present in memory. The request generation component produces 10,000 requests. Each request is either an allocation or deallocation, specified by process ID and memory size (for allocations) or process ID (for deallocations). For this simulation, each process makes only one request, either for memory allocation or deallocation. Requests may be generated randomly or based on trace data. When a deallocation request is processed, the entire memory allocated to that process is freed. For each request, the simulation must invoke the appropriate Memory component functions across both of the two chosen techniques, recording three key performance metrics: Average number of external fragments (holes of 1 or 2 units). Average allocation time, measured by the average nodes traversed during allocation.


Turn static files into dynamic content formats.

Create a flipbook
The Objective Of This Weeks Lab Is To Simulate And Evaluate by Dr Jack Online - Issuu