kernel: add assert for mis-used k_thread_create()
k_thread_create() works as expected on both uninitialized memory, or threads that have completely exited. However, horrible and difficult to comprehend things can happen if a thread object is already being used by the kernel and k_thread_create() is called on it. Historically this has been a problem with test cases trying to be parsimonious with thread objects and not properly cleaning up after themselves. Add an assertion for this which should catch both the illegal creation of a thread already active, or threads racing to create the same thread object. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
9c9312c8c5
commit
e0ca403f4c
3 changed files with 22 additions and 0 deletions
|
@ -516,6 +516,12 @@ struct _thread_base {
|
|||
#endif
|
||||
|
||||
_wait_q_t join_waiters;
|
||||
#if __ASSERT_ON
|
||||
/* For detecting calls to k_thread_create() on threads that are
|
||||
* already active
|
||||
*/
|
||||
atomic_t cookie;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct _thread_base _thread_base_t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue