L4Re Operating System Framework
Interface and Usage Documentation
|
Basic slab allocator. More...
#include <slab_alloc>
Data Structures | |
struct | Slab_i |
Type of a slab. More... | |
Public Types | |
enum | { object_size = Obj_size , slab_size = Slab_size , objects_per_slab = (Slab_size - sizeof(Slab_head)) / object_size , max_free_slabs = Max_free } |
typedef Alloc< Slab_i > | Slab_alloc |
Type of the backend allocator. | |
Public Member Functions | |
void * | alloc () noexcept |
Allocate a new object. | |
void | free (void *_o) noexcept |
Free the given object (_o ). | |
unsigned | total_objects () const noexcept |
Get the total number of objects managed by the slab allocator. | |
unsigned | free_objects () const noexcept |
Get the number of objects which can be allocated before a new empty slab needs to be added to the slab allocator. | |
Basic slab allocator.
Obj_size | The size of the objects managed by the allocator (in bytes). |
Slab_size | The size of a slab (in bytes). |
Max_free | The maximum number of free slabs. When this limit is reached slabs are freed, provided that the backend allocator supports allocated memory to be freed. |
Alloc | The backend allocator used to allocate slabs. |
Definition at line 42 of file slab_alloc.
anonymous enum |
Enumerator | |
---|---|
object_size | Size of an object. |
slab_size | Size of a slab. |
objects_per_slab | Objects per slab. |
max_free_slabs | Maximum number of free slabs. |
Definition at line 76 of file slab_alloc.
|
inlinenoexcept |
Allocate a new object.
Definition at line 218 of file slab_alloc.
References cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::free(), cxx::H_list< T, POLICY >::push_front(), and cxx::H_list< T, POLICY >::remove().
Referenced by cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::alloc().
|
inlinenoexcept |
Free the given object (_o
).
Definition at line 257 of file slab_alloc.
References cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::max_free_slabs, cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::objects_per_slab, cxx::H_list< T, POLICY >::push_front(), cxx::H_list< T, POLICY >::remove(), and cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::slab_size.
Referenced by cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::alloc(), and cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::free().
|
inlinenoexcept |
Get the number of objects which can be allocated before a new empty slab needs to be added to the slab allocator.
Definition at line 319 of file slab_alloc.
References cxx::Bits::Basic_list< POLICY >::begin(), cxx::Bits::Basic_list< POLICY >::end(), and cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::objects_per_slab.
Referenced by cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::free_objects().
|
inlinenoexcept |
Get the total number of objects managed by the slab allocator.
Definition at line 310 of file slab_alloc.
References cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::objects_per_slab.
Referenced by cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::total_objects().