Lhogho  0.0.027
Pools

Introduction

Pools implement a general memory manager mechanism. Every pool represents a dynamic storage of atoms of specific fixed size. Atoms of different sizes must be handled by separate pools.

Pool structure

A pool points two storages of atoms - a block of consequitive free atoms and a list of chained free atoms (see pool_t structure)

pool_structure.png
Pool structure (pool_t)

The pool maintains two pointers. The first one, free_atom, points to a free atom. Each atom has the same size, which is specified in the atom_size field of the pool. Free atoms are chained in a list (note: this is not a Lhogho list). At the beginning of each atom in the list there is a pointer to the next atom of the list. The other pool pointer is to a block of free atoms. Each block is created with space for block_size number of atoms each of which is atom_size bytes big, free_block_atoms determines the actual number of free atoms in the block. This number decreases as the atoms from the block become allocated.

Atom allocation

The pool implementation is responsible for allocating and deallocating atoms in Lhogho. Follows the algorithm for atom allocation as implemented in take_from_pool function():

The allocation algorithm is tuned to serve allocation request as fast as it is possible. The majority of requests will be served by the first step two steps which need constant time.

Atom deallocation

Deallocated atoms are returned back to the pool and can be later reallocated. Follows the algorithm for atom deallocation as implemented in return_to_pool function().

The deallocation algorithm is tuned to return atoms to the pool as fast as it is possible. It works for a constant time. Returned atoms are always placed in the list and never in the block.


[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Tue Feb 7 2012