Hi
i have gone through Tim Robins memor management tutorial -1 , in which he talks about the basic memory manager. The primary responsibilities of the basic memory mnager are described as allocation of physical page, deallocation , and then there is a memory mapper section. I dont fully understand what its purpose is. if anybody has read it and could help me out I would really appreciate it
Cant fully understand Tim Robin's memory management tutorial
Hello,
He is talking about two basic systems:
1. The Page Frame Allocator
2. The Memory Allocator (malloc() and so on).
The page frame allocator (on the x86 architecture) needs to allocate in multiples of 0x1000 (4096) bytes, as this is the minimum amount of RAM that can be paged in by your OS. Because of this size restriction, it is often best to keep either an allocation bitmap or stack of free pages.
The problem with allocating a page at a time, is that often you will just want to do something like malloc(sizeof(mystruct)), where the structure could only be 12 bytes long, for example. In this case, you have wasted 4084 bytes, as you can only allocate in multiples of 4096 bytes.
That's where the higher-level memory allocator comes in. This can allocate any aount of RAM from 1 byte upwards (in reality, probably you will use 4-byte multiples to keep everything 32-bit aligned). For this system, you need to create something like a linked-list of allocated and free memory blocks. Every time you allocate memory, you add to the list of allocated blocks and remove from the list of free blocks. Freeing is the reverse of this. Note that although I say 'blocks', if you have no memory allocated, you would just have a single entry in the free list spanning over the entire heap. It is only when memory becomes fragmented that you start needing more than one entry in the free list.
The physical allocator and virtual manager can be two entirely separate entites. You can let your virtual allocator return pointers to un-paged RAM and simply let the physical allocator page-in every time there is a page fault exception in an assigned area.
HTH
Adam
He is talking about two basic systems:
1. The Page Frame Allocator
2. The Memory Allocator (malloc() and so on).
The page frame allocator (on the x86 architecture) needs to allocate in multiples of 0x1000 (4096) bytes, as this is the minimum amount of RAM that can be paged in by your OS. Because of this size restriction, it is often best to keep either an allocation bitmap or stack of free pages.
The problem with allocating a page at a time, is that often you will just want to do something like malloc(sizeof(mystruct)), where the structure could only be 12 bytes long, for example. In this case, you have wasted 4084 bytes, as you can only allocate in multiples of 4096 bytes.
That's where the higher-level memory allocator comes in. This can allocate any aount of RAM from 1 byte upwards (in reality, probably you will use 4-byte multiples to keep everything 32-bit aligned). For this system, you need to create something like a linked-list of allocated and free memory blocks. Every time you allocate memory, you add to the list of allocated blocks and remove from the list of free blocks. Freeing is the reverse of this. Note that although I say 'blocks', if you have no memory allocated, you would just have a single entry in the free list spanning over the entire heap. It is only when memory becomes fragmented that you start needing more than one entry in the free list.
The physical allocator and virtual manager can be two entirely separate entites. You can let your virtual allocator return pointers to un-paged RAM and simply let the physical allocator page-in every time there is a page fault exception in an assigned area.
HTH
Adam