Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Operating Systems Design Lab Lab 8 : Memory Allocation Objectives 1 . Write a C program to simulate the following variable partition size memory allocation
Operating Systems Design Lab
Lab : Memory Allocation
Objectives
Write a C program to simulate the following variable partition size memory allocation algorithms:
a Bestfit: chooses the smallest memory hole that is big enough to accommodate the request.
b Worstfit: chooses the largest memory hole that is big enough to accommodate the request.
c Firstfit: chooses the first memory hole that is big enough to accommodate the request.
Prelab
Review Chapter of the textbook.
Experiment
Write a program that takes the following as an input:
Number of processes N
The size of the total memory in bytes.
The scheduling algorithm to use : Bestfit, : Worstfit, : Firstfit
The user is requested to enter the total memory size in bytes and the number of processes. Then, the program
randomizes the arrival time between and and lifetime between and of every process. It also randomizes
the memory requirements so that the total memory required by all processes does not exceed the total memory size.
Then, the program asks the user to choose the algorithm. Memory is then allocated to processes using the algorithm of
choice. Note that when a process terminates, its allocated memory becomes free. With every allocationdeallocation
operation, your program must print the list of memory holes and the baselimit values of the allocated memory. If
not hole is big enough to accommodate the current memory request, your program should report this case showing
the total size of available memory.
Here is a sample run:
INPUT
Enter the memory size
Enter the number of processes
Generating random timeline
PROCESS ARRIVAL TIME LIFETIME MEMORY REQUIREMENTS
P
P
P
Choose algorithm BEST WORST FIRST
OUTPUT
List of memory holes
Allocating memory to P at time : Base Limit
List of memory holes
Allocating memory to P at time : Base Limit
List of memory holes
Deallocating memory of P at time
List of memory holes
Allocating memory to P at time : Base Limit
List of memory holes
Deallocating memory of P at time :
List of memory holes
Deallocatig memory of P at time :
List of memory holes
Done
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started