MATLAB: Do I encounter compilation issues when multitasking in Polyspace Bug Finder

arxmlautosarmicrosarmultitaskingoilosekPolyspace Bug Finder

I have an existing project in Polyspace Bug Finder/Code Prover that runs perfectly, but when I enable multitasking I encounter several compilation errors in Os.h. Why does this occur and how do I work around it?

Best Answer

When using multitasking with AUTOSAR products (MICROSAR, etc.), there is an ARXML or OIL file type that uses keywords to control the multitasking. Several of these Keywords such as ActiveTask, ISR, etc. are repeated in the AUTOSAR products as functions rather than keywords. This causes confusion for the compiler and results in compilation errors.
There are four current workarounds:
1. The first is to add a Macro in the configuration settings, or manually edit the files to replace all of the conflicting names with other names. For example, add 'ActiveTask=MyActiveTask' in the configuration setting Target&Compiler > Macros > Preprocessor definitions to remove any issues with ActiveTask or ActivateTask keywords. Alternatively if using the Command Line to run Polyspace, use the flag -D ActiveTask=MyActiveTask.
2. The second workaround is to avoid using the keyword files and instead manually setup the multitasking. Information about the different ways to set up multitasking can be found below:
3. The third workaround is to use a -post-preprocessing-command option with a Perl script like the one below:
#!/usr/bin/perl
#
binmode STDOUT;
while ($line = <STDIN>)
{
# comment StatusType OSEK_polyspace_ActivateTask(OSEK_task_polyspace_TaskType TaskID);
$line =~ s/(StatusType\s+OSEK_polyspace_ActivateTask\s*\(.*\)\s*;)/\/\* PS $1 \*\//g;
# Comment StatusType OSEK_get_resource_polyspace_ResourceType ResId();
$line =~ s/(StatusType\s+OSEK_get_resource_polyspace_ResourceType\s+ResId\(\s*\)\s*;)/ \/\* PS $1 \*\//g;
# Replace StatusType OSEK_polyspace_TerminateTask with StatusType OSEK_polyspace_TerminateTask_ps
$line =~ s/$\s*(StatusType\s+OSEK_polyspace_TerminateTask)/ $1_ps/g;
print $line;
}
4. (*Recommended*) The last workaround is to use 'Configure Multitasking manually'.
When launching analysis, and in the log file, you can see the following information below, allowing you to help for configuring tasks manually:
_* Starting parsing of ARXML files.
** Parsing file "C:\myproject\myarxml.arxml".
Remark: Multitasking configuration found in ARXML files
| * TASK (-entry-points) Ts1100ms, Ts210ms, Ts31ms, TsInit
| * ISR (-interrupts) Isr1, Isr2, irq11ms, irqs2
| ..._
Then search in your source code the name of function _Ts1100ms and then add its name directly to option -entry-points. Note that function name is not *Ts1100ms *but something like T*ASK(Ts1100ms)* where TASK is a MACRO that changes slightly the name of the function.
For instance, in some OS*.h you will find out MACRO definition like this:
#define TASK(x) Task_##x
It means that you will have to add real name in option like -entry-points Task_Ts1100ms.
That is same for ISR as well.
_