OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 8:05 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Hidden BrokenThorn tutorial 26
PostPosted: Mon Apr 29, 2019 4:00 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
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


Top
 Profile  
 
 Post subject: Re: Hidden BrokenThorn tutorial 26
PostPosted: Mon Apr 29, 2019 3:11 pm 
Offline
Member
Member

Joined: Sat Sep 24, 2016 12:06 am
Posts: 90
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.


Top
 Profile  
 
 Post subject: Re: Hidden BrokenThorn tutorial 26
PostPosted: Mon Apr 29, 2019 5:28 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
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

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Hidden BrokenThorn tutorial 26
PostPosted: Mon Apr 29, 2019 7:50 pm 
Offline
Member
Member

Joined: Wed Dec 12, 2018 12:16 pm
Posts: 119
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!


Top
 Profile  
 
 Post subject: Re: Hidden BrokenThorn tutorial 26
PostPosted: Tue Apr 30, 2019 12:14 am 
Offline
Member
Member
User avatar

Joined: Mon Jul 13, 2009 5:52 am
Posts: 99
Location: Denmark
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?).


Last edited by zity on Wed May 01, 2019 11:44 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Hidden BrokenThorn tutorial 26
PostPosted: Tue Apr 30, 2019 4:55 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Hidden BrokenThorn tutorial 26
PostPosted: Tue Apr 30, 2019 9:11 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
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.


Top
 Profile  
 
 Post subject: Re: Hidden BrokenThorn tutorial 26
PostPosted: Fri May 03, 2019 8:35 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
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.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group