Main Page   Interface   Data Structures   File List   Data Fields   Globals  

BFA.c File Reference

Balloon Flight Allocation Routines. More...

#include <stdlib.h>
#include <string.h>
#include "BBC/BUG.h"
#include "BBC/RNG.h"
#include "BFU/BFA.h"
#include "BFU/BFU_fileDsc.h"

Data Structures

struct  _BFA_acb
 Balloon Flight Allocation Control Block. More...

struct  _BFA_rcb
 Underlying ring buffer. More...


Typedefs

typedef _BFA_rcb BFA_rcb
 Typedef for stuct _BFA_rcb.


Functions

int initBfa (BFA_rcb *brcb, struct _RNG_rcb *rcb, unsigned char *pool, int pool_size, int max_alloc_size)
 Initializes a BFA ring buffer control structure. More...

int BFA_copy (BFA_acb *acb, void *eop)
 Copies any piece of memory that spills into the overflow area back to the top of the ring buffer pool. More...

_BFU_fileDscBFA_get (BFA_acb *acb, int nevts, int nsums, int nbytes)
 Allocates the requested number of bytes for the requested number of events. More...

BFA_acbBFA_open (int dsc_pool_size, int dsc_max_alloc_size, int evt_pool_size, int evt_max_alloc_size)
 Allocates the control structure and memory for the BFA allocator. More...

_RNG_rcb * BFA_evtRcbGet (const BFA_acb *acb)
 Simple query routine to get the control structure of the event descriptors ring buffer that BFA is managing. More...

_RNG_rcb * BFA_dscRcbGet (const BFA_acb *acb)
 Simple query routine to get the control structure of the event ring buffer that BFA is managing. More...

int BFA_evtRcbReset (BFA_acb *acb)
 Resets the event ring buffer to its initial state. More...

int BFA_dscRcbReset (BFA_acb *acb)
 Resets the event descriptor ring buffer to its initial state. More...


Detailed Description

Balloon Flight Allocation Routines.

Author:
JJRussell - russell@slac.stanford.edu
ABSTRACT
--------
Provides the Balloon Flight DAQ memory manager

DESCRIPTION
-----------
The memory manager is just a thin layer on top of the Ring Buffer Management routines. Its basic value added is to manage the copying of data when it spills into the overflow area of the ring buffer.


Function Documentation

int BFA_copy BFA_acb   acb,
void *    eop
 

Copies any piece of memory that spills into the overflow area back to the top of the ring buffer pool.

Parameters:
scb  Memory allocator's control block.
eop  Pointer to the end of the packet.
Returns:
If positive or 0, the number of bytes copied. If negative an error.
Checks to see if any piece of the packet defined by 'eop' (end of packet address) lives in the overflow area. If it does, then a piece of memory is allocated at (it must be at the top of the buffer) and the piece in the overflow area is copied into that area. Note that by definition a data packet always starts within the the ring buffer proper.

The eop pointer must also be, be definition, the next allocation pointer.

struct _RNG_rcb * BFA_dscRcbGet const BFA_acb   acb
 

Simple query routine to get the control structure of the event ring buffer that BFA is managing.

Parameters:
acb  Memory allocator's control block handle.
Returns:
The Ring Buffer Control Structure handle.

int BFA_dscRcbReset BFA_acb   acb
 

Resets the event descriptor ring buffer to its initial state.

Parameters:
acb  Memory allocator's control block handle.
Returns:
Status. Failure indicates the ring buffer was not empty.
The ring buffer must be empty for this routine to be successful.

struct _RNG_rcb * BFA_evtRcbGet const BFA_acb   acb
 

Simple query routine to get the control structure of the event descriptors ring buffer that BFA is managing.

Parameters:
acb  Memory allocator's control block handle.
Returns:
The Ring Buffer Control Structure handle.

int BFA_evtRcbReset BFA_acb   acb
 

Resets the event ring buffer to its initial state.

Parameters:
acb  Memory allocator's control block handle.
Returns:
Status. Failure indicates the ring buffer was not empty.
The ring buffer must be empty for this routine to be successful.

struct _BFU_fileDsc * BFA_get BFA_acb   acb,
int    nevts,
int    nsums,
int    nbytes
 

Allocates the requested number of bytes for the requested number of events.

Parameters:
acb  Memory allocator control block handle.
nevts  The number of events that need to be described.
ma nsums The number of summary records.
Parameters:
nbytes  The number of bytes to allocate
Returns:
If successful, a pointer to the allocated event descriptor, else NULL.

struct _BFA_acb * BFA_open int    dsc_pool_size,
int    dsc_max_alloc_size,
int    evt_pool_size,
int    evt_max_alloc_size
 

Allocates the control structure and memory for the BFA allocator.

Parameters:
dsc_pool_size  The event descriptor pool size.
dsc_max_alloc_size  The size, in bytes, of the maximum descriptor.
evt_pool_size  The event pool size, in bytes.
evt_max_alloc_size  The size, in bytes, of the maximum event allocation.
Returns:
If successful, a handle to the pool, else NULL.
Allocates and initializes a memory pool for BFA's use. Two pools are allocated, one to allocate memory for the event data and one for allocation of event descriptors

Each memory pool is divided into three pieces. The total size is set by the 'pool_size'. An underflow area is allocated at the top of the pool and an overflow area is allocated at the bottom. These areas allow the internal memory manager to satisfy requests up to 'max_alloc_size' as contigious chunks of memory that also obey blocking (chunking) constraints.

int initBfa BFA_rcb   brcb,
struct _RNG_rcb *    rcb,
unsigned char *    pool,
int    pool_size,
int    max_alloc_size
[static]
 

Initializes a BFA ring buffer control structure.

Parameters:
brcb  The BFA ring buffer control structure to initialize
rcb  The underlying ring buffer control structure
pool_size  The event descriptor pool size.
max_alloc_size  The size, in bytes, of the maximum allocation.
Returns:
If successful, a handle to the pool, else NULL.


Generated on Tue Mar 5 17:55:28 2002 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002