MISRA C:2012 Dir 5.3
Description
This checker is deactivated in a default Polyspace® as You Code analysis. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).
Rule Definition
There shall be no dynamic thread creation.1
Rationale
Dynamic thread creation results in uncertainty about the number of threads running at a specific point in your code. This uncertainty makes the code error-prone and makes the code more difficult to maintain and debug. Instead of creating threads dynamically, use static thread pools instead.
Polyspace Implementation
Polyspace reports violations of this rule if any of these conditions are true:
Thread creation functions such as
thrd_create()
orpthread_create()
are called outsidemain()
or a designated startup function.Thread creation functions are called in a loop that is not bounded by a constant.
This Datalog code specifies foo()
as the startup function
that creates the threads in your
code:
.include "pql/checkers/thrd_create_unsafe.dl" ThrdCreateUnsafe.is_unique_function_thrd_create("foo").
main()
and the startup function, Polyspace reports a violation.For more information about using Datalog to modify Bug Finder checkers, see Datalog Format.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Concurrency considerations |
Category: Required |
AGC Category: Required |
Version History
Introduced in R2025b
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.