GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBS / V2-12-1 > pbs / mv2304
#include <PBS/FPA.h>
#include <PBS/LI.h>
#include <PBS/LI.ih>
Classes | |
struct | _FPA_fcb |
Layouts the control structure for managing the list of free packets. This structure is private to the FPA utility. More... | |
Functions | |
static __inline FPA_pcb * | allocate (FPA_fcb *fcb, void *unused) |
Basic non-interlocked version of the routine to allocate a packet from the free list. | |
int | FPA_fcb_sizeof () |
Returns the size of the Fixed Packet Allocator control block. | |
int | FPA_init (FPA_fcb *fcb, FPA_type type, void *buffer, int buf_size, int packet_size, int pcb_offset, FPA_init_cb init_routine, void *init_parameter) |
Configures a user supplied piece of memory as a collection of fixed size packets which can be allocated and deallocated. | |
int | FPA_destroy (FPA_fcb *fcb) |
Releases any resources gathered at initialization time. | |
void __inline * | FPA_get (FPA_fcb *fcb) |
Get or allocate a packet from the free list. | |
void * | FPA_getW (FPA_fcb *fcb) |
Get or allocate a packet from the free list with a indefinite blocking. | |
void * | FPA_getW_toc (FPA_fcb *fcb, const TOC *toc) |
Get or allocate a packet from the free list using the timeout specified by TOC. | |
int | FPA_free (FPA_fcb *fcb, void *packet) |
Returns a previously allocated packet to the free list. |
CVS $Id: FPA.c,v 1.7 2011/03/24 23:05:46 apw Exp $
Basic non-interlocked version of the routine to allocate a packet from the free list.
NULL,on | failure (empty free list) | |
Pointer | to the allocated packet, on success |
fcb | The FPA handle | |
unused | Not used. |
References _LI_head::head, L__remove(), _FPA_fcb::list, _FPA_fcb::outstanding, and _FPA_fcb::pcboff.
Referenced by FPA_get(), FPA_getW(), and FPA_getW_toc().
int FPA_destroy | ( | FPA_fcb * | fcb | ) |
Releases any resources gathered at initialization time.
fcb | The handle of the Fixed Packet Allocator |
References LI_destroy(), and _FPA_fcb::list.
int FPA_fcb_sizeof | ( | void | ) |
Returns the size of the Fixed Packet Allocator control block.
This call is for modularity reasons. The user can learn the size of memory needed by the FPA utility to manage a pool of packets without needing to know the details of how it is laid out. This could have also been achieved by having the FPA initialization routine allocate the control block, but this takes away the freedom of the user to control his own allocation and deallocation
Referenced by WUT_sys_init().
int FPA_free | ( | FPA_fcb * | fcb, | |
void * | packet | |||
) |
Returns a previously allocated packet to the free list.
fcb | The handle of the Fixed Packet Allocator. | |
packet | The packet to be freed. |
References _LI_head::head, L__insert(), _FPA_fcb::list, _FPA_pcb::node, _FPA_fcb::outstanding, _FPA_fcb::pcboff, _LI_head::rw, RW__lock(), RW__unlock(), and RW__wake().
Referenced by WUT_destroy().
void __inline* FPA_get | ( | FPA_fcb * | fcb | ) |
Get or allocate a packet from the free list.
fcb | The handle of the Fixed Packet Allocator |
References allocate(), _FPA_fcb::list, _LI_head::rw, RW__lock(), and RW__unlock().
Referenced by FPA_getW(), FPA_getW_toc(), and WUT_create().
void* FPA_getW | ( | FPA_fcb * | fcb | ) |
Get or allocate a packet from the free list with a indefinite blocking.
fcb | The handle of the Fixed Packet Allocator |
References allocate(), FPA_get(), _FPA_fcb::list, _LI_head::rw, and RW_getW().
Get or allocate a packet from the free list using the timeout specified by TOC.
fcb | The handle of the Fixed Packet Allocator. | |
toc | The timeout control structute. |
References allocate(), FPA_get(), _FPA_fcb::list, _LI_head::rw, and RW_getW_toc().
int FPA_init | ( | FPA_fcb * | fcb, | |
FPA_type | type, | |||
void * | buffer, | |||
int | buf_size, | |||
int | packet_size, | |||
int | pcb_offset, | |||
FPA_init_cb | init_routine, | |||
void * | init_parameter | |||
) |
Configures a user supplied piece of memory as a collection of fixed size packets which can be allocated and deallocated.
fcb | The handle of the Fixed Packet Allocator to be initialized. The user is responsible for supplying the memory for the control structure. | |
type | The type of blocking to be used | |
buffer | A pointer to the user-supplied buffer. This buffer must be 32-bit aligned. The packets will be carved from this memory. | |
buf_size | The size, in bytes, of the user-supplied buffer. | |
packet_size | The size, in bytes, of the packets. This number must be an integral number of 32-bit words. This ensures that all packets will be properly aligned. | |
pcb_offset | Offset, in bytes, to the packet control block. This block is necessary for managing the packet while it is on in the free pool, but is free for the user to do with as he wishes when once the packet has been allocated. This parameter allows the user to control the placement of the control block. This offset is generally specified as 0, in which case the control structure is at the top of the packet, or -1, in which case the links are at the bottom of the packet. The latter case is especially useful if one wishes to initialize the top portion of the packet with a static header of some sort, while the bottom of the packet contains data to be filled in later when the packet is allocated. | |
init_routine | The address of the entry point of a user supplied routine which is called as each new packet is placed on the free list. This parameter may be NULL if no initialization routine is needed. It is the user's responsibility not so use the control area. This is possible, since the user knows the size and controls its placement in the packet. Set FPA_init_cb for the definition of the callback signature. | |
init_parameter | A user supplied parameter which is passed to the callback routine. |
Various options allow the user to place where the control structure lives within the packet and determine the blocking style. The most usual choice for the placement of the packet control structure is at the beginning pcb_offset = 0, or at the end pcb_offset = -1, although the user is allowed to specify any offset, provided it is within the packet. The usual blocking style is FPA_K_TYPE_FIFO_BLOCKING.
References _FPA_fcb::buffer, _FPA_fcb::bufsize, FPA_K_PCB_AT_EOP, LI_init(), LI_insert(), _FPA_fcb::list, _FPA_pcb::node, _FPA_fcb::outstanding, _FPA_fcb::pcboff, _FPA_fcb::pcktcnt, and _FPA_fcb::pcktsize.
Referenced by WUT_sys_init().