2

I'm trying to simulate an OS.

Say I'm given x bytes of memory.
How would I go about designing a best fit memory allocation system?

I am planning to create an array to store multiple memory block objects, each containing some amount of the total memory size. Example:

Total size is 100 bytes

b1=20, b2=30, b3 =10, b4= 15, b5 =25

  1. Is there a specific way to go about generating each block size?
  2. What happens if a process requires 50 memory? None of the blocks will be able to support the process. Should I just refuse the process since none of my blocks can support it or should I merge blocks etc.
cadaniluk
  • 15,027
  • 2
  • 39
  • 67
Nych
  • 78
  • 1
  • 3
  • 10
  • Answer to 2-> You should think about defragging your blocks to form a bigger coalesce of block which would serve the request. You should try to support the process, till it is within the capacity of the RAM and SWAP space. – Am_I_Helpful Nov 12 '15 at 07:02

0 Answers0