Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement memory simulation in C?

Basically I need to have two lists, one of which keeps the list of empty memory holes by storing the starting point and the size of each hole. The other one, keeps information about various processes (while there is no actual process data, rather just the id and starting location and size).

So, I understand that I will need to have two structs, each of which defines the "hole" and the "process". I will need to have two lists to store these objects.

What I don't understand, is how to "initialize memory". For example, if the user wants to initialize(5000 bytes), what should the initialize method do in respect to the two lists?

like image 568
antonpug Avatar asked Apr 08 '26 09:04

antonpug


1 Answers

You just empty the process list (since no memory is allocated) and create a single hole from address 0 to address 4999 (since those addresses are empty).

like image 51
David Schwartz Avatar answered Apr 10 '26 00:04

David Schwartz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!