How to avoid copying arrays with waveformRecord

From EPICSWIKI
Revision as of 15:45, 19 February 2013 by MichaelDavidsaver (talk | contribs)

Introduction

This page describes how to use the array field memory management feature to be introduced in EPICS 3.15.1 (not yet released). This allows array data to be moved into and out of the value (aka BPTR) field of the waveform, aai, and aao types.

Making use of this feature involves replacing the pointer stored in the BPTR field with another (user allocated) pointer. The basic rules are:

  1. BPTR, and the memory it is currently pointing to, can only be accessed while the record is locked.
  2. NELM may not be changed.
  3. BPTR must always point to a piece of memory large enough to accommodate the maximum number of elements (as given by the NELM field).

Rule #1 means that it is only safe to read, write, or de-reference the BPTR field from a device support function, or after manually calling dbScanLock(). Rule #3 means that BPTR can never be set to NULL, and when replacing BPTR, the replacement must be allocated large enough for the worst case. An external client may put an array of up to NELM elements to the field at almost any time.


Prerequisites

A version of EPICS Base with this feature.

Example