Embedded Xinu Network Playground COSC3300Fall2012
Buffer Pool API

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...

Functions

void * bufget (int)
syscall buffree (void *)
int bfpalloc (ulong, ulong)

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:
bufsizesize of individual buffers in bytes
nbufcount of bufsize buffers in pool
Returns:
index into bfptab of initialized pool, SYSERR on failure
syscall buffree ( void *  buffer)

Return buffer to pool.

Parameters:
bufferaddress of returning buffer
Returns:
OK on success, SYSERR on failure
void* bufget ( int  poolid)

Acquire buffer from initialized pool.

Parameters:
poolidindex of pool in bptab
Returns:
pointer to buffer on success, SYSERR on failure