Chapter 5 Generated Code Architecture
© National Instruments Corporation 5-49 AutoCode Reference
/**** declare pointer to shared variables ****/
volatile struct _shared_varblk *isi_varblk[1] = {&shared_var_blks};
@ENDIFF@
Example 5-21 assumes the existence of a fictional shared memory target
such that the compiler supports #pragmas to declare the shared memory
region. Your compiler and architecture will most likely have a different
mechanism.
The following list shows the requirements for shared variable block
support. All of the steps can be accomplished within the template using
template parameters.
• Create a structure (record) containing the name and data type of the
shared variable blocks in the model. This structure should be visible to
the code on each processor, or must be declared static. The source
file(s) for each processor must have a declaration of the structure.
• Declare an instance of the structure containing the shared variable
blocks into shared memory. This will vary, depending on your
compiler’s and target’s shared memory architecture.
• Declare a static variable named isi_varblk that is an array (or a
pointer in C) and assign the 0th element to the location in shared
memory where the shared variable block structure is placed. Refer to
Example 5-22.
For Ada, the template code will be identical except that you must
transliterate the C syntax into Ada syntax and the shared memory allocation
will be different.
Example 5-22 Shared Variable Block Generated Code with Callouts (-vbco)
/* ------------------------------- Read from Variable */
Enter_Shared_Varblk_Section(4);
proc2_4_1 = isi_varblk[0]->block5[0];
proc2_4_2 = isi_varblk[0]->block5[1];
Leave_Shared_Varblk_Section(4);
/* ------------------------------- Write to Variable */
Enter_Shared_Varblk_Section(4);
isi_varblk[0]->block5[0] = proc2_4_1;
isi_varblk[0]->block5[1] = proc2_4_2;
Leave_Shared_Varblk_Section(4);