Advanced: Creating Customized OSIs : Customizing API Definitions : General API Definitions : Critical Section APIs

Critical Section APIs
 
Sample Definition
Code Generated
Declare Critical Section(nameid)
extern CRITICAL_SECTION $<nameid>;
Defines the code for declaring a Critical Section (OS Object).
This API is used when generating the code for declaring a Critical Section.
This code is generated in the file type_def.h
For a Critical Section named: critical_section:
extern CRITICAL_SECTION critical_section;
Define Critical Section(nameid)
CRITICAL_SECTION $<nameid>;
Defines the code for defining a Critical Section (OS Object).
This API is used when generating the code for defining a Critical Section.
This code is generated in the file glob_dat.c
For a Critical Section named: critical_section:
CRITICAL_SECTION critical_section;
Create Critical Section(nameid)
$<nameid> = CreateCriticalSection();
Defines the code for creating a Critical Section (OS Object).
This API is used when generating the code for creating a Critical Section.
This code is generated in the file glob_dat.c, in the function on_startup_code.
The function on_startup_code is called at the startup of the generated application.
For a Critical Section named: critical_section:
critical_section = CreateCriticalSection();
Destroy Critical Section(nameid)
DestroyCriticalSection($<nameid>);
Defines the code for destroying a Critical Section (OS Object).
This API is used when generating the code for destroying a Critical Section.
This code is generated in the file glob_dat.c, in the function on_exit_code.
The function on_exit_code is called at the end of the generated application.
For a Critical Section named: critical_section:
DestroyCriticalSection(critical_section );
Enter Critical Section(nameid)
EnterCriticalSection($<nameid>);
Defines the code for entering a Critical Section (OS Object).
Used when entering a critical section.
For example, swapping the double buffered buffers of a Task, may require guarding this code section. The code generator uses this API just before swapping the buffers.
For a Critical Section named: critical_section:
EnterCriticalSection(critical_section );
End Critical Section(nameid)
Defines the code for ending a Critical Section (OS Object).
Used when exiting a critical section.
For example, swapping the double buffered buffers of a Task, may require guarding this code section. The code generator uses this API just after the swapping the buffers.
For a Critical Section named: critical_section:
EndCriticalSection(critical_section );