The Buffer Pool API provides a mechanism for pre-allocating a pool of buffers to be used in time-sensitive components where the linear-time search of malloc() would be undesirable.
More...
Detailed Description
The Buffer Pool API provides a mechanism for pre-allocating a pool of buffers to be used in time-sensitive components where the linear-time search of malloc() would be undesirable.
For example, in the network stack we allocate a pool of buffers at initialization time. As packets arrive, free buffers from the pool are used to hold packet data during processing. When a particular packet has completed its journey, the buffer is returned to the pool.
Function Documentation
int bfpalloc |
( |
ulong |
bufsize, |
|
|
ulong |
nbuf |
|
) |
| |
Acquire heap storage and subdivide into buffers.
- Parameters:
-
bufsize | size of individual buffers in bytes |
nbuf | count of bufsize buffers in pool |
- Returns:
- index into bfptab of initialized pool, SYSERR on failure
syscall buffree |
( |
void * |
buffer | ) |
|
Return buffer to pool.
- Parameters:
-
buffer | address of returning buffer |
- Returns:
- OK on success, SYSERR on failure
void* bufget |
( |
int |
poolid | ) |
|
Acquire buffer from initialized pool.
- Parameters:
-
poolid | index of pool in bptab |
- Returns:
- pointer to buffer on success, SYSERR on failure