harish kumar

harish kumar

  • NA
  • 1
  • 2.4k

memory management

Oct 26 2013 7:18 PM
Implement a list based memory management system with two
versions of mem alloc using first-fit and best-fit policy respectively. The input consists of multiple
lines. Each line starts with a keyword, which is one of "init", "alloc" or "dealloc". The line starting
with "init" keyword has two numbers, total available memory (a number between 1 and 231 - 1,
and a string "best-fit" or "first-fit". 0 indicates first-fit policy and 1 indicates best-fit policy. The
number after the keyword "alloc" gives the number of memory units for the allocation request. The
line with "dealloc" keyword takes a number. For example, dealloc 1 means that the allocation made
by the first allocation request is being returned. In general, "dealloc" k means that the allocation
made by the kth allocation request, is being returned.


Sample Input.
init 1000 first-fit
alloc 340
alloc 110
dealloc 1
alloc 200
alloc 300
dealloc 2
alloc 205




Sample Output.
(allocated, 0, 200) (allocated, 200,205) (free,405, 50) (allocated,450,300) (free, 750,250)


Answers (1)