Comments (4)
for threads we should distinguish the memory required for the thread control block and the stack.
normally threadTerminate() should be used for a different thread (this restriction should be mentioned in the manual), and in this case the thread stack can be fully freed when terminate() returns.
for threadExit() things are a bit more complicated, since this function is called on the context of the current thread, which means the current stack cannot be freed while executing thread code, so the thread should be added to a list of threads to be deleted, and the list should be iterated by another thread and terminated threads will be finally deleted (usually this happens on the idle thread, but any other strategy is ok).
the conclusion is that threads exiting themselves may take a while to be deleted.
regarding the delete function, for consistency reasons, the CMSIS++ RTOS C API defines a os_thread_delete()
, which deallocates the thread control block allocated by os_thread_new()
.
actually CMSIS++ defines two pairs of functions for each object, for example:
void os_thread_construct (os_thread_t* thread, const char* name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t* attr);
void os_thread_destruct (os_thread_t *thread);
and
os_thread_t* os_thread_new (const char* name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t* attr);
void os_thread_delete (os_thread_t *thread);
the construct/destruct are exactly the C++ constructor/destructor, while new/delete are exactly the C++ new/delete, which, in addition to construct/destruct, allocate/deallocate memory for the thread control block.
this highly consistent mechanism is used for all CMSIS++ system objects.
from cmsis_5.
Ok now I know how this is solved in CMSIS++. But how is it handled in CMSIS 5. This is still unclear to me.
Thanks
Joachim
from cmsis_5.
CMSIS-RTOS2 has a thread attribute osThreadJoinable (see http://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html). When osThreadJoinable is not set osThreadTerminate instantly deletes the thread. When osThreadJoinable is set, you must use osThreadJoin to release the resources of the thread.
from cmsis_5.
closing as there is no further question on that
from cmsis_5.
Related Issues (20)
- Possible bugs in `__STREXW` and `__LDREXW` in cmsis_armcc.h and cmsis_armclang.h HOT 5
- SVD multiple enumeratedValues occurrences meaning HOT 2
- Filter State variable access with Python Wrapper for arm_biquad_casd_df1_inst_f32 HOT 1
- Issues with new ARMv8 MPU attributes HOT 1
- Issue with osDelay in TC_osKernelResume_1 HOT 2
- RTX4 EXCLUSIVE_ACCESS macro undefined for GCC compiler HOT 2
- Versioning of CMSIS Core missmatch HOT 3
- Add HOST support HOT 2
- Output Mismatch in ARM mult , scale, Complex real mult in CMSIS 5.9 version HOT 1
- `CMSIS_DEPRECATED` for Cortex M? HOT 1
- Error in the description of CMSIS-SVD HOT 1
- The number of `enumeratedValue` elements in the `enumeratedValues` element if the `derivedFrom` attribute is present HOT 6
- EMAC_iMXRT1064.c file is not compatible with fsl_enet driver in Keil HOT 3
- [SVDConv] `writeConstraint` in `register` crashes SVDConv HOT 2
- How to build a library in the Ti env. HOT 1
- Thread switch on osKernelRestoreLock? HOT 2
- RTOS2 - memory block pools vs byte pools? HOT 7
- armv8-m register define doesn't include BPU HOT 2
- Extension of osKernelGetTickCount() to provide monotonic tick counter is in error. HOT 3
- Git LFS Data Limit Exceeded HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmsis_5.