Creating DSP/BIOS Objects Dynamically
Program Generation
2-17
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.
Example 2-1.
Creating and Referencing Dynamic Objects
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.
Example 2-2.
Deleting a Dynamic Object
Dynamically-created DSP/BIOS objects allow for a program to adapt at
runtime.
#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);
TSK_delete (task);
Summary of Contents for TMS320 Series
Page 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Page 16: ...xvi ...
Page 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Page 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Page 202: ...5 20 ...
Page 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Page 288: ...Index 10 Index ...