OSDev.org
https://forum.osdev.org/

Hidden BrokenThorn tutorial 26
https://forum.osdev.org/viewtopic.php?f=1&t=33673
Page 1 of 1

Author:  thomtl [ Mon Apr 29, 2019 4:00 am ]
Post subject:  Hidden BrokenThorn tutorial 26

I was browsing google for info on slab allocators and I found an article/tutorial on them(and other designs) by BrokenThorn in their OSDev Tutorials, but it isn't featured on their page it isn't even on their (dead) forums so I thought i'd post it here. The reason they aren't on the main page is that it still isn't done. But someone might find them useful.

link: http://brokenthorn.com/Resources/OSDev26.html

Author:  MrLolthe1st [ Mon Apr 29, 2019 3:11 pm ]
Post subject:  Re: Hidden BrokenThorn tutorial 26

Hi, thomtl. Thanks for hidden tutorial, it can be useful for begginers. Nice work!
But, for example, i'm using TLSF in kernel. It better, than anyone self-written allocator, in last versions i had a AVL-Tree-based allocator. It complexity works O(log2( free blocks count)), but in real tests, TLSF is better. Also, you can use DLmalloc, but it requieres a tonns of dependecies to work properly.

Author:  kzinti [ Mon Apr 29, 2019 5:28 pm ]
Post subject:  Re: Hidden BrokenThorn tutorial 26

MrLolthe1st wrote:
Also, you can use DLmalloc, but it requieres a tonns of dependecies to work properly.


Mmm... All dlmalloc needs is "sbrk()" or "mmap()" and a few minor things like "error()" and "abort()". This isn't "tons of dependencies".

Example using mmap():
https://github.com/kiznit/rainbow-os/bl ... ot/crt.cpp

Example using sbrk() (this one includes locking for MP support).
https://github.com/kiznit/rainbow-os/bl ... l/heap.cpp

Author:  deleted8917 [ Mon Apr 29, 2019 7:50 pm ]
Post subject:  Re: Hidden BrokenThorn tutorial 26

I've finished writing my memory manager, it stills being very basic. (because tutorials about that are almost non-existant sadly).
I haven't look the tutorial completely, but seems to be good, it can be helpful for me. Thanks thomtl!

Author:  zity [ Tue Apr 30, 2019 12:14 am ]
Post subject:  Re: Hidden BrokenThorn tutorial 26

During the last few weeks I started working on the SLAB allocator, and there are many good resources around the web. The original papers by Bonwick are quite easy to understand, and there is also good documentation about the implementation in Linux. For those interested, I post a few references here.


On a slightly different topic, I am also trying to understand how to properly use AVL trees for allocating virtual memory addresses, but I am yet to solve the issue of coalescing free memory regions (maybe two separate trees, one ordered by size and one ordered by address?).

Author:  bzt [ Tue Apr 30, 2019 4:55 am ]
Post subject:  Re: Hidden BrokenThorn tutorial 26

Hi,

If you're looking for a simple and fast allocator, may I recommend bztalloc, which has several advantages over dlmalloc, ptmalloc, Hoard and SLAB:

* minimal dependencies (memcpy, memzero, mmap, munmap, that's all, and mmap is always called anonymously without an fd)
* it does not mix allocator data and application data
* can be used in single threaded and multi threaded environments
* can support any threading library, not just pthreads
* works on so called arenas, so you can use the same library for kernel heap, user space, shared memory etc. at the same time

It worth mentioning that jemalloc() usually outperforms it, but jemalloc() is a lot more complex and lot more difficult to port. This bztmalloc is a nice compromise between performance, low memory footprint and easy portability.

Cheers,
bzt

Author:  thomtl [ Tue Apr 30, 2019 9:11 am ]
Post subject:  Re: Hidden BrokenThorn tutorial 26

Thanks all, I'm currently using a very simple SLAB allocator by some other tutorial but when i'm going to improve it i'm definitely going to take a look at these.

Author:  neon [ Fri May 03, 2019 8:35 pm ]
Post subject:  Re: Hidden BrokenThorn tutorial 26

Hi,

We would be happy to extend the chapter to include additional content and release it as an independent chapter if you believe it might be helpful. It was never officially released due to long term concerns over the lack of maintainability of the current production/demo release process that would have effected about 11 chapters at that time.

However... We are currently executing an internal experiment that may allow us to be able to continue the series as its complexity grows. Provided the process is successful, we may be able to translate all current chapters with better support for additional tool chains and start writing new chapters soon.
Quote:
but I am yet to solve the issue of coalescing free memory regions (maybe two separate trees, one ordered by size and one ordered by address?)
Sounds like you have the right idea here. Cannot comment much more without details, however using two trees as you described is common.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/