Differentiating between different memory managers

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
leekimpark
Posts: 3
Joined: Thu Jul 12, 2012 2:25 am

Differentiating between different memory managers

Post by leekimpark »

In spite of my very basic understanding of operating systems, recently I've been doing a lot of research into the memory managers that different Unix-like operating systems use, particularly how they allocate memory to processes. My goal has been trying to compare the differences across different operating systems I've learned things like free lists, memory pools, power of two lists, and the buddy system. I've also learned about slab allocation. The problem is that I'm not sure which category of memory manager these schemes are used for. Most of these terms I found in books for specific operating systems under the section explaining the kernel memory allocator. Is this supposed to be allocating memory for the kernel's data structures, or for allocating memory for processes or can it be used for both? I'm particularly worried about slab allocation and which one of the two categories it falls in. :?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Differentiating between different memory managers

Post by JamesM »

The slab allocator is normally used for allocating small sizes of memory, and is used in Linux's kernel heap (malloc for the kernel).

It's used as a general purpose kmalloc and also specialised caches (in slab parlance) are created for instances that are often created and destroyed - inodes, for example.
leekimpark
Posts: 3
Joined: Thu Jul 12, 2012 2:25 am

Re: Differentiating between different memory managers

Post by leekimpark »

In that case, what about the other allocators, and for Linux, what is used to allocate memory for processes?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Differentiating between different memory managers

Post by JamesM »

leekimpark wrote:In that case, what about the other allocators, and for Linux, what is used to allocate memory for processes?
As far as I'm aware, linux divvys up the virtual address space with a buddy allocator.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Differentiating between different memory managers

Post by gerryg400 »

allocating memory for the kernel's data structures
Linux now uses the SLUB allocator which is an improved SLAB allocator for small pieces of memory
allocating memory for processes
Each process lives in its own address space. You need an allocator that can allocate out of that memory. Generally it's best to represent a process address space as a list (implemented as a tree usually but a linked list might do in a simple OS) of already allocated groups of pages. Think about how mmap might work. Just search the list for a space as big as the user requested, usually combine that used space to an already-in-use space and return to the user.

IMHO, even though it's a little old, the Gorman book is a good way to learn Linux MM.
If a trainstation is where trains stop, what is a workstation ?
leekimpark
Posts: 3
Joined: Thu Jul 12, 2012 2:25 am

Re: Differentiating between different memory managers

Post by leekimpark »

I'm still confused about the whole process behind allocating memory for processes. For the kernel memory allocator that allocates for kernel data structures, the kernel just requests pages from the virtual memory manager, and then may use something like SLAB or SLUB. I've also seen the term kernel memory allocator being used interchangeably with general memory allocator for example at http://docs.freebsd.org/44doc/papers/kernmalloc.html and http://www.ibm.com/developerworks/aix/l ... index.html. From these sources and others, I originally thought that the kernel memory allocator was used for both the kernel's own data structures as well as process creation, but it seems that this is not the case and there is a separate allocation scheme. I've seen the thread here http://forum.osdev.org/viewtopic.php?t=12022 but it hasn't really helped. I took a look at at the gormon book and I'm still not sure how process creation works.
Post Reply