kernel - Simple toy OS memory management -


I am developing a simple small toy OS in C and Assembly as an experiment, but I have to worry about myself I've felt a lack of knowledge on system memory.

I am able to compile the kernel, run it in Boch (loaded by GRUB), and call it "Hello, world!" Print Now I am trying to make a simple memory manager so that I can start experimenting with other things.

I got some resources on memory management, but they really did not have enough code to pass (as I had understood this concept, but actually learning about implementing it I had suffered a loss.)

I tried some more or less complex strategies, then a ridiculous simplified one (just offset in one memory and increase it by the size of the allotted object) Is not required. There is no fission control, protection or nothing yet.

So I would like to know where I can get more information for a more robust manager and I would like to know more about paging, division, and other relevant things. So far, I have not dealt with it, but I have mentioned it often in OS Development Sites, so I'm guessing that I have to deal with it sooner or later.

I 'has also read about some form of indirect sign, where an application contains an indicator which is redirected by the memory manager to its actual location. It matters a lot to me, I'm sure, but it seems important that I ever want to try virtual memory or defragmentation.

And also, where should I put off my memory? I did not know what was the best place, so I randomly chose 0x1000 , and I'm pretty sure that when I overwrite my kernel or something, then come back later Will happen.

I would also like to know that I should be expecting performance-wise (eg bigger values ​​for allocation and release) and what is the proper proportion of memory management structures in real management memory.

Of course, do not hesitate to answer just one subset of these questions. Any feedback is greatly appreciated!

If you do not already know about it, then a good resource is general, and memory There are many articles on management, if you are looking for a particular memory allocation algorithm, then I suggest reading the "buddy system" method (http://en.wikipedia.org/wiki/Buddy_memory_allocation). I think you might find an example implementation on the Internet. If you can get a copy in a library, it is also possible to read part of the dedicated computer programming for memory management (Volume 1, section 2.5).

I do not know where you should get memory offsets (honestly I've never written a kernel), but whatever happened to me can be a work, a stable at the end of the kernel After entering that variable, start the allocation after that address. Something like this:

  (in Memory Manager) extern char endOfKernel; ... (even in memory manager) myOffset = & amp; EndOfKernel; ... (End of file which is finally placed in binary) Four EndOffers;   

I think it goes without saying, but how serious you are about the operating system, you probably wish to have some books on the operating system design and if you want it to be school Keeping in OS Class will not hurt to pick up.

Comments