Texas Instruments TMS320 User Manual page 47

Dsp/bios v5.40
Hide thumbs Also See for TMS320:
Table of Contents

Advertisement

Example 2-1. Creating and Referencing Dynamic Objects
Example 2-2. Deleting a Dynamic Object
Most XXX_create functions accept as their last parameter a pointer to a
structure of type XXX_Attrs which is used to assign attributes to the newly-
created object. By convention, the object is assigned a set of default values
if this parameter is NULL. These default values are contained in the constant
structure XXX_ATTRS listed in the header files, enabling you to first initialize
a variable of type XXX_Attrs and then selectively update its fields with
application-dependent attribute values before calling XXX_create. Sample
code that creates a dynamic object using the TSK_create is shown in
Example 2-1.
#include <tsk.h>
TSK_Attrs
attrs;
TSK_Handle
task;
attrs = TSK_ATTRS;
attrs.name = "reader";
attrs.priority = TSK_MINPRI;
task = TSK_create((Fxn)foo, &attrs);
The XXX_create function passes back a handle that is an address to the
task's object. This handle is can then be passed as an argument when
referencing, for example, deleting the object, as shown in Example 2-2.
Objects created with XXX_create are deleted by calling the function
XXX_delete. This frees the object's internal memory back to the system for
later use.
Use the global constant XXX_ATTRS to copy the default values, update its
fields, and pass as the argument to the XXX_create function.
TSK_delete (task);
Dynamically-created DSP/BIOS objects allow for a program to adapt at
runtime.
Creating DSP/BIOS Objects Dynamically
Program Generation
2-17

Advertisement

Table of Contents
loading

Table of Contents