GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > PBS / V2-10-10

Constituent: test_rng     Tag: rad750


Interface   Data Structures   File List   Data Fields   Globals  

test_rng.c File Reference

Unit test for the Ring Buffer Allocator (RNG) facility. More...


Detailed Description

Unit test for the Ring Buffer Allocator (RNG) facility.

Author:
JJRussell - russell@slac.stanford.edu
   CVS $Id

The RNG routines are one of the main memory managers offered by PBS. They provide a method of managing a block of memory as a ring buffer. The allocations and frees are performed in an interlocked fashion.

The facility is meant to aid the user in implementing the all resource allocations upfront FSW policy. The user can allocate a pool of memory using the random allocator MBA_alloc() or MBA_align(), then manage that pool within a task or collection of tasks using the RNG routines.

The advantages of the RNG routines are

  1. Fast and deterministic
  2. Interlocked
  3. Fine-grain time-out support
  4. Random size allocation

In the world of memory allocators, one cannot have it all. The main feature missing is

  1. Out of order freeing not allowed

This last restriction limits the RNG buffer to a single producer (allocator) running in a one task, passing memory to a single producer (freer) running in another task. With a little thought, the user can make the RNG buffer routines work in a multi-producer, single consumer environment. To do the most general topology of multi-producer, multi-consumer, the user must arrange the freeing to be done in order.

This version of the RNG buffer takes care of the wrap around problem without user intervention during allocation provided the user is willing to live with the constraint of a maximum allocation size. The RNG facility accomplishes this by augmenting the end of the ring buffer proper with an overflow region the size of the maximum event size.

In addition there is a further advanced feature that allows the user to map fixed sized blocks onto the ring buffer without a minimum of copying. This is useful when packing variable sized events into fixed size blocks that are destined to an output device. This is accomplished by not only appending an overflow region to the end of the main memory pool, but also prepending an underflow region to the beginning of the main memory pool.

The test can be run from the command line by typing

   $ test_rng

Generated on Mon Nov 20 05:38:36 2006 by  doxygen 1.4.4