Chapter 5 Generated Code Architecture
AutoCode Reference 5-48 ni.com
Example 5-21 shows template code to generate the required structure and pointer. All of the necessary information about the shared variable blocks is accessible from within the template using parameter information.
Example 5-21 Template Code to Generate Required Shared Variable Block Structures (C)
@IFF multiprocessor_b@@
@shared_count = 0@@
@
/**** declare shared variable block structure ****/
static struct _shared_varblk {
@LOOPP k=0, k lt nvars_i, k=k plus 1@@
@IFF vars_prsr_scope_li[k] eq 2 or vars_prsr_scope_li[k] eq 3@@
@shared_count = shared_count + 1@@
@
@/declare shared variable block
@
@vars_typ_pfix_ls[k]@ @vars_ls[k]@
@
@/generate dimensions, if array
@offset = vars_sfix_dim_start_li[k]@@
@LOOPP m=0, m lt vars_typ_sfix_dim_li[k], m=m plus 1@@
[@vars_typ_sfix_li[offset]@]@
@offset = offset plus 1@@
@ENDLOOPP@@
;
@ENDIFF@@
@ENDLOOP@@
@/if no varblks shared, must create a dummy element
@IFF shared_count eq 0@@
RT_INTEGER ignore;
@ENDIFF@@
};
/**** declare shared variables in shared memory ****/
#pragma SHARED_MEM_BEGIN
struct _shared_varblk shared_var_blks;
#pragma SHARED_MEM_END