C11 (https://en.cppreference.com/w/c/languag ... e_duration) and C++11 (https://en.cppreference.com/w/cpp/langu ... e_duration) introduce language keywords for thread local storage.
While it may be possible to define CH_CFG_THREAD_EXTRA_FIELDS to get some sort of thread local storage, it's not portable to POSIX or other OSes, so support for thread_local / _Thread_local would be nice.
Support for C11/C++11 thread local storage
- stertingen
- Posts: 21
- Joined: Mon Jan 13, 2020 10:55 pm
- Has thanked: 7 times
- Been thanked: 7 times
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Support for C11/C++11 thread local storage
Hi,
That is a compiler development, the OS already supports mechanisms able to implement that. For example a private heap that is destroyed on thread termination (using hooks).
Giovanni
That is a compiler development, the OS already supports mechanisms able to implement that. For example a private heap that is destroyed on thread termination (using hooks).
Giovanni
- alex31
- Posts: 379
- Joined: Fri May 25, 2012 10:23 am
- Location: toulouse, france
- Has thanked: 38 times
- Been thanked: 62 times
- Contact:
Re: Support for C11/C++11 thread local storage
the OS already supports mechanisms able to implement that. For example a private heap that is destroyed on thread termination (using hooks).
That's nice, can be useful for allocating memory from a dma compatible pool in a reentrant way. Is there any example of using this ?
Alexandre
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Support for C11/C++11 thread local storage
No examples so far, I am thinking to make the heap allocator "thread aware", each thread could allocate private blocks that are released on thread termination (or explicitly).
This would require an extra field in the header structure because each block would be linked to the thread using a list. It would also better support that C++ feature, no need to use hooks at all.
Giovanni
This would require an extra field in the header structure because each block would be linked to the thread using a list. It would also better support that C++ feature, no need to use hooks at all.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 65 guests