Interrupts (-interrupts
)
Specify functions that represent nonpreemptable interrupts
Description
The option is not available for code generated from MATLAB® code or Simulink® models.
Specify functions that represent nonpreemptable interrupts. The analysis assumes that operations in the function body:
Can execute any number of times.
Cannot be interrupted by noncyclic tasks, cyclic tasks or other interrupts. Noncyclic tasks are specified with the option
Tasks (-entry-points)
and cyclic tasks are specified with the optionCyclic tasks (-cyclic-tasks)
.You can also make interrupts preemptable.
To model an interrupt that can be interrupted by other interrupts, specify the interrupt as preemptable. See
-preemptable-interrupts
. For examples, see Define Task Priorities for Data Race Detection in Polyspace.To make only a section of an interrupt preemptable, call a routine enabling all interrupts before that section and call another routine disabling all interrupts after the section is complete. For instance, if you specify the routine
isr()
as an interrupt, it is nonpreemptable by default. However, withinisr()
, if you call a routine enabling all interrupts, the section following the call is preemptable till you call another routine disabling all interrupts:For information on how to enable and disable all interrupts, seevoid isr() { x++; //Nonpreemptable enable_all_interrupts(); //Routine enabling interrupts y++; //Preemptable disable_all_interrupts(); //Routine disabling interrupts z++; //Nonpreemptable }
Disabling all interrupts (-routine-disable-interrupts -routine-enable-interrupts)
.
Set Option
User interface (desktop products only): In your project configuration, the option is available on the Multitasking node. See Dependencies for other options you must also enable.
User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Static Analysis tab on the Multitasking node. See Dependencies for other options you must also enable.
Command line and options file: Use the option
-interrupts
. See Command-Line Information.
Why Use This Option
Use this option to specify interrupts in your multitasking code. The functions that you specify must have the prototype:
void function_name(void);
A Bug Finder analysis uses your specifications to look for concurrency defects.
For the Data race
defect, the analysis
establishes the following relations between interrupts and other tasks:
Data race between two interrupts:
Two operations in different interrupts cannot interfere with each other (unless one of the interrupts is preemptable). Even if the operations use the same shared variable without protection, a data race cannot occur.
Data race between an interrupt and another task:
An operation in an interrupt cannot interfere with an atomic operation in any other task. Even if the operations use the same shared variable without protection, a data race cannot occur.
An operation in an interrupt can interfere with a nonatomic operation in any other task unless the other task is also a nonpreemptable interrupt. Therefore, if the operations use the same shared variable without protection, a data race can occur.
For more information, see:
A Code Prover verification uses your specifications to determine:
Whether a global variable is shared.
See Global Variables.
Whether a run-time error can occur.
For instance, if the operation
var=INT_MAX;
occurs in an interrupt andvar++
occurs in the body of a task, an overflow can occur if the interrupt executes before the operation in the task. The analysis detects the possible overflow.
Settings
No Default
Enter function names or choose from a list.
Click to add a field and enter the function name.
Click to list functions in your code. Choose functions from the list.
Dependencies
To enable this option in the user interface of the desktop products, first select the
option Configure multitasking manually
.
Tips
In Code Prover, the functions representing interrupts must have the form
void functionName (void)
If a function
func
takes arguments or returns a value, you cannot use it directly as an interrupt. To usefunc
as an interrupt, callfunc
from a wrappervoid
-void
function and specify the wrapper as an interrupt. See Configuring Polyspace Multitasking Analysis Manually.If you specify a function as an interrupt, you must provide its definition. Otherwise, a Code Prover verification stops with the error message:
task func_name must be a userdef function without parameters
A Bug Finder analysis continues but does not consider the function as an interrupt.
If you run a file by file verification in Code Prover, your multitasking options are ignored. See
Verify files independently (-unit-by-unit)
.The Polyspace® multitasking analysis assumes that an interrupt cannot interrupt itself.
Code Prover interprets this option with some limitations. The reason is that Code Prover considers all operations as potentially non-atomic and interruptible. This overapproximation leads to situations where the option might appear to be ignored. For an example, see Effect of Task Priorities in Code Prover.
Command-Line Information
Parameter: -interrupts |
No Default |
Value:
|
Example (Bug Finder): polyspace-bug-finder
-sources |
Example (Code Prover):
polyspace-code-prover -sources |
Example (Bug Finder Server): polyspace-bug-finder-server -sources |
Example (Code Prover Server):
polyspace-code-prover-server -sources |
Version History
Introduced in R2016b