About Memory Management

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
OSMAN

About Memory Management

Post by OSMAN »

Hi.

Now I have the interrupts working. I am wondering what should I do next in my monolithic system. Maybe a memory manager. But I don't understand why does one need pages defined by GDT and so on, when one can point everywhere in the memory by a single address-value (in C) and implement the partitioning of the memory at any level of the kernel. Please tell me that.

PS. What are the modern algorithms for allocating and deallocating memory?
AR

Re:About Memory Management

Post by AR »

Segmentation restricts which areas of virtual memory can be accessed, A segment that starts at 0x1000 and goes to 0x2000 which is then used as DS will cause a wraparound (or a GPF, can't remember which) if the offset is more than 0xFFF.

Flat segmentation removes this concern. The point of the memory manager is that you aren't going to be able to fit everything in memory all the time, so you need memory manager to share the memory between programs. The approaches available vary, physical management can be a bitmap, a stack, a list, etc. Virtual management is generally just allocate on demand, if there isn't any free memory then steal someone elses page that hasn't be used for the longest. There are also additional features like periodic theft (taking a rarely used page from a program despite no-one else needing more pages in order to build up a surplus).

And as always, the basics of this is also in the Wiki. As well as some directions on what order to build things in.
JoeKayzA

Re:About Memory Management

Post by JoeKayzA »

AR wrote: Segmentation restricts which areas of virtual memory can be accessed, A segment that starts at 0x1000 and goes to 0x2000 which is then used as DS will cause a wraparound (or a GPF, can't remember which) if the offset is more than 0xFFF.
A GPF exception, AFAIK, the system gets informed that a segment limit was exceeded, so the faulty task can be killed.

cheers Joe
Post Reply