Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
Data Structures | Macros | Functions
slab.h File Reference
#include <common/list.h>
Include dependency graph for slab.h:

Go to the source code of this file.

Data Structures

struct  kmem_cache
 
struct  slab
 

Macros

#define CACHE_PAGE_SIZE   256
 
#define CACHE_NAME_LEN   16
 
#define CACHE_OPT_NONE   0
 

Functions

struct kmem_cachekmem_cache_create (const char *name, size_t size, size_t align, unsigned long flags, void(*ctor)(void *))
 Create a new slab cache. More...
 
void * kmem_cache_alloc (struct kmem_cache *cache, unsigned long flags)
 Allocate a new slab memory. More...
 
void kmem_cache_free (struct kmem_cache *cache, void *obj)
 Free the allocated slab memory. More...
 
void kmem_cache_init (void)
 

Function Documentation

◆ kmem_cache_alloc()

void* kmem_cache_alloc ( struct kmem_cache cache,
unsigned long  flags 
)

Allocate a new slab memory.

Parameters
cacheThe cache object for managing slabs.
flagsNot used.
Return values
void*: Pointer to the allocated slab memory.

◆ kmem_cache_create()

struct kmem_cache* kmem_cache_create ( const char *  name,
size_t  size,
size_t  align,
unsigned long  flags,
void(*)(void *)  ctor 
)

Create a new slab cache.

Parameters
nameName of the cache.
sizeSize of the slab managed by the cache.
alignSize of the slab memory should be aligned to.
flagsNot used.
ctorNot used.
Return values
structkmem_cache *: Pointer to the new allocated cache.

◆ kmem_cache_free()

void kmem_cache_free ( struct kmem_cache cache,
void *  obj 
)

Free the allocated slab memory.

Parameters
cacheThe cache object for managing slabs.
objPointer to the allocated slab memory.
Return values
None