smalloc short from Static memory buffer malloc, is an ideal memory manager for Realtime Linux Kernel modules that can't use dynamic m
smalloc short from Static memory buffer malloc, is an ideal memory manager for Realtime Linux Kernel modules that can't use dynamic memory offered by kmalloc because of the non-realtime nature of kmalloc.
Like malloc(), smalloc() doles out memory to client code. Unlike malloc, however, smalloc takes a static memory buffer (as an initialization parameter). It is this buffer that smalloc manages when doling out memory to client code.
This design makes smalloc ideal for use inside a Realtime Linux kernel module. It also makes it much easire to port userspace code that relies on malloc() in C or operator new() in C++ for memory management to a realtime kernel module.
(the below is linux kernel code)
< code >
#include < linux/slab.h >
#define MEMPOOLSZ (1024*1024*1024)
buf = kmalloc(MEMPOOLSZ, GFP_KERNEL); /* 1 megabyte buffer in kernel
s = smalloc(sizeof(MyStruct)); /* example of code that uses this
static memory buffer */
< /code >
The above example is a typical usage pattern of smalloc.
tags kernel module static memory linux kernel memory buffer code that client code out memory realtime linux
Download smalloc 1.0
Other software in this category
- Desktop Environment
- Science and Engineering
- Text Editing&Processing