Cyclic tasks (-cyclic-tasks
)
Specify functions that represent cyclic tasks
Description
The option is not available for code generated from MATLAB® code or Simulink® models.
Specify functions that represent cyclic tasks. The analysis assumes that operations in the function body:
Can execute any number of times.
Can be interrupted by noncyclic tasks, other cyclic tasks and interrupts. Noncyclic tasks are specified with the option
Tasks (-entry-points)
and interrupts are specified with the optionInterrupts (-interrupts)
.To model a cyclic task that cannot be interrupted by other cyclic tasks, specify the task as nonpreemptable. See
-non-preemptable-tasks
. For examples, see Define Task Priorities for Data Race Detection in Polyspace.
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
-cyclic-tasks
. See Command-Line Information.
Why Use This Option
Use this option to specify cyclic tasks 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 software
establishes the following relations between preemptable tasks and other tasks.
Data race between two preemptable tasks:
Unless protected, two operations in different preemptable tasks can interfere with each other. If the operations use the same shared variable without protection, a data race can occur.
If both operations are atomic, to see the defect, you have to enable the checker Data race including atomic operations.
Data race between a preemptable task and a nonpreemptable task or interrupt:
An atomic operation in a preemptable task cannot interfere with an operation in a nonpreemptable task or an interrupt. Even if the operations use the same shared variable without protection, a data race cannot occur.
A nonatomic operation in a preemptable task also cannot interfere with an operation in a nonpreemptable task or an interrupt. However, the latter operation can interrupt the former. 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 (Polyspace Code Prover).
Whether a run-time error can occur.
For instance, if the operation
var++
occurs in the body of a cyclic task and you do not impose a limit onvar
, the operation can overflow. 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 cyclic tasks must have the form
void functionName (void)
If a function
func
takes arguments or returns a value, you cannot use it directly as a cyclic task. To usefunc
as a cyclic task:, callfunc
from a wrappervoid
-void
function and specify the wrapper as a cyclic task. See Configuring Polyspace Multitasking Analysis Manually.If you specify a function as a cyclic task, 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 a cyclic task.
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 a task 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 (Polyspace Code Prover).
Command-Line Information
Parameter: -cyclic-tasks |
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
See Also
-preemptable-interrupts
| -non-preemptable-tasks
| Interrupts (-interrupts)
| Tasks (-entry-points)
| Show global
variable sharing and usage only (-shared-variables-mode)
(Polyspace Code Prover)