![]() |
![]() |
![]() |
![]() |
![]() |
Optimization and Configuration
Optimization and configuration is mainly performed in two .h files. These are auto_cfg.h and extreme_user_cfg.h. The file auto_cfg.h is generated by the Cextreme Code Generator, and contains the optimization and configuration that can be automatically computed given the system that code is generated for. The extreme_user_cfg.h file is generated by The Targeting Expert from configuration information provided by the user.
auto_cfg.h
The auto_cfg.h has the contents discussed below. The first section in the file is used to configure mainly the size of some arrays and the size (8, 16, or 32 bits) needed to represent certain entities.
#define CFG_NUMBER_PROCESS_TYPES 2#define CFG_MAX_INSTANCES 1#define CFG_NUMBER_TIMERS 0#define CFG_MAX_TIMER_INSTS 0#define CFG_NUMBER_SIGNALS 4#define CFG_NUMBER_THREADS 0#define CFG_MAX_ACTIONS 2#define CFG_MAX_STATES 1#define CFG_MAX_STATE_INDEX_ENTRY 2In the second section information is given about what concepts that are used in the system that code is generated for. For concepts that are used a #define is generated, while for concepts not used, a comment, saying the corresponding macro is not defined, is generated. The information in this section is used to scale the code, to remove code and fields in data structures that is not needed.
#define CFG_USED_DYNAMIC_THREADS#define CFG_USED_UNLIMITED_INSTANCES#define CFG_USED_TIMER#define CFG_USED_CREATE#define CFG_USED_STOP#define CFG_USED_SAVE#define CFG_USED_STATE_STAR#define CFG_USED_INPUT_SAVE_STAR#define CFG_USED_GUARD#define CFG_USED_SIGNAL_WITH_PARAMS#define CFG_USED_TIMER_WITH_PARAMS#define CFG_USED_SIGNAL_WITH_DYN_PARAMS#define CFG_USED_SENDER#define CFG_USED_OFFSPRING#define CFG_USED_PARENT#define CFG_USED_SELF#define CFG_USED_PROCEDURE#define CFG_USED_RPC#define CFG_USED_INITFUNCThe third section contains information about items in connection with data types, used to remove code in the file sctpred.c not needed by the generated application. The section contains a sequence of defines looking like the example below.
#define XNOUSE_"at-lot-of-things-about-data-types"In rare cases the auto_cfg.h file might contain information that does not fit the application to be built. One such case is if the third section contains information that a certain function is not used, and therefore removed with ifdefs. The function is, however, used in user provided C code, in for example the environment functions. In such cases it is possible to override the information in auto_cfg.h by including macro definitions last in extreme_user_cfg.h.
Example 643 : Assume the auto_cfg.h contains
#define XNOUSE_LENGTH_CHARSTRINGwhich shows that the length function for character strings are not used. To override this the following code should be included in uml_cfg.h:
#ifdef XNOUSE_LENGTH_CHARSTRING#undef XNOUSE_LENGTH_CHARSTRING#endifextreme_user_cfg.h
This file is generated by the Targeting Expert and contains information about the options that you have selected.
extreme_user_cfg.h is, just as auto_cfg.h, a file that should contain defines that are used to build the Cextreme Code Generator application with specified options. The file extreme_user_cfg.h will include auto_cfg.h.
Some of the features discussed below can be selected in the Targeting Expert and will affect the contents of the extreme_user_cfg.h file. The options not included in the UI can be inserted in the file directly, just make sure that your modifications won't be overwritten by the Targeting Expert.
Process properties
Signal properties
- #define USER_CFG_MAX_SIGNAL_INSTS <Integer>
- #define USER_CFG_NOUSE_DYNAMIC_SIGNALS
- #define USER_CFG_SIGNALS_NEVER_DISCARDED
- Define to remove the code for freeing signal parameters in case a signal is discarded. Only applicable if signals with dynamic parameters are used. If XMK_USED_SIGNAL_WITH_DYN_PARAMS is defined in auto_cfg.h. If USER_CFG_SIGNALS_NEVER_DISCARDED is defined and a signal with dynamic parameters is discarded there will be a memory leak.
- #define USER_CFG_USE_SIGNAL_PRIORITIES
- #define USER_CFG_TIMER_PRIO <Integer>
- #define USER_CFG_CREATE_PRIO <Integer>
- #define USER_CFG_DEFAULT_PRIO <Integer>
- #define USER_CFG_MSG_BORDER_LEN <Integer>
Timer properties
- #define USER_CFG_MAX_TIMER_INSTS <Integer>
- Length of static timer queue. The default length is the computed value CFG_MAX_TIMER_INSTS from auto_cfg.h, which in case of timers without parameters is the maximum amount of possible active timers. In case of timers with parameters this value can, in extreme cases, be to small. Normally a value smaller than CFG_MAX_TIMER_INSTS might be used. If dynamic timers are not used (compare with USER_CFG_NOUSE_DYNAMIC_TIMERS), an error occurs if the timer queue is full at the same time as an attempt to set a timer is made.
- #define USER_CFG_NOUSE_DYNAMIC_TIMERS
- #define USER_CFG_TIMER_SCALE <Integer>
Dynamic memory allocation
- #define USER_CFG_USE_MEMORY_PACK
- #define USER_CFG_USE_MEMORY_PACK <Integer>
- #define USER_CFG_MEMORY_MIN_BLOCKSIZE <Integer>
Error detection
- #define USER_CFG_ERR_CHECK_BASIC
- Turn on checking of basic state machine properties:
- No more memory for signal sending or create
- No more memory to allocate the parameters of a signal
- No more memory for timer instance
- xOutEnv() is not present and signal is sent to the environment
- Signal is discarded
- Cannot create more instances as maximum limit reached
- Public attribute access error
- #define USER_CFG_ERR_CHECK_INDEX
- #define USER_CFG_ERR_CHECK_RANGE
- #define USER_CFG_ERR_CHECK_PREDEF_O
- #define USER_CFG_ERR_CHECK_DECISION
- #define USER_CFG_ERR_CHECK_NULL_PTR
- #define USER_CFG_ERR_CHECK_MEMORY_PACK
- #define USER_CFG_ERROR_MESS_STDOUT
- #define USER_CFG_ERROR_MESS_STDERR
- #define USER_CFG_USE_ERR_MESS
- #define USER_CFG_WARN_ACTION
- #define USER_CFG_ERR_ACTION
Miscellaneous
- #define USER_CFG_USE_xInitEnv
- #define USER_CFG_USE_xCloseEnv
- #define USER_CFG_USE_xInEnv
- #define USER_CFG_USE_xOutEnv
- #define USER_CFG_ADD_STDIO
- #define USER_CFG_UML_TRACE_STDOUT
- #define XUSE_TYPEINFONODE_CFG
Code generation commands
There are some options in the Targeting Expert that is passed to the code generator, sdtsan, and does not affect the extreme_user_cfg.h file. The purpose is to be able to generate as readable code as possible, which is also the default. If certain features are needed, that will affect the readability, these features can be selected individually. These options can be found in the "SDL to C compiler"-tab, in the group "Code generation options".
- Amount of comments (Set-Extreme-C-Comments)
- Generate Run Time Tests (Set-Extreme-C-Run-Time-Test)
- Generate Sdt references (Set-Extreme-C-Sdt-Ref)
- Generate trace code (Set-Extreme-C-Trace)
- Use Signal Priorities (Set-Extreme-C-Signal-Prio)
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |