#3835 closed enhancement (fixed)
Support statically allocated threads
Reported by: | Sebastian Huber | Owned by: | Sebastian Huber |
---|---|---|---|
Priority: | normal | Milestone: | 5.1 |
Component: | score | Version: | 5 |
Severity: | normal | Keywords: | qualification |
Cc: | Blocked By: | #3838 | |
Blocking: |
Description (last modified by Sebastian Huber)
In some applications it is desirable to have statically allocated resources for all operating system objects.
In addition to the thread control block, up to four memory areas are currently allocated by a thread:
- stack area
- TLS area
- FP context
- thread queue heads
Currently the FP context and the TLS area are separately allocated from the workspace. This complicates the workspace size estimate. Add the FP context and TLS size to the stack size and place them in the stack area. This makes it also possible to move the stack area allocation out of _Thread_Initialize(). Use a hook to get the thread queue heads which is configured depending on the unlimited objects option of the configuration.
Statically allocate the stacks for internal threads (e.g. idle and MPCI receive server) in a dedicated linker section (similar to the interrupt stacks). Mention this in the Classic API Guide configuration chapter.
Change History (41)
comment:1 Changed on 12/09/19 at 11:47:18 by Chris Johns
comment:2 Changed on 12/09/19 at 11:55:41 by Sebastian Huber
Nothing stops you from reallocating the TLS area on demand. In the worst case you waste a bit of memory. I don't think this change here will add constraints to libdl.
comment:3 Changed on 12/09/19 at 11:58:24 by Sebastian Huber
For clarification, the pointer to the TLS area in the thread control block will remain as is.
comment:5 Changed on 12/09/19 at 12:38:58 by Joel Sherrill
In at least two applications I have helped with that had custom allocators, this sounds like it might not work. They had special mmu permissions on their stack memory.
comment:6 follow-up: 8 Changed on 12/09/19 at 12:51:01 by Sebastian Huber
I would consider the FP context and the thread-local storage of a thread to be in the same access domain. These data areas should be private to a thread.
comment:7 Changed on 12/11/19 at 14:26:21 by Sebastian Huber
Blocked By: | 3838 added |
---|
comment:8 follow-up: 9 Changed on 12/12/19 at 18:09:46 by Joel Sherrill
Replying to Sebastian Huber:
I would consider the FP context and the thread-local storage of a thread to be in the same access domain. These data areas should be private to a thread.
I don't know if this was intended to respond to my concern with custom stack allocators or not. In the systems I know have used this, the memory is not available (mapped dynamically) or known statically (RTEMS runs in virtual address space).
How does this work with custom stack allocators?
comment:9 Changed on 12/12/19 at 18:54:18 by Sebastian Huber
Replying to Joel Sherrill:
Replying to Sebastian Huber:
I would consider the FP context and the thread-local storage of a thread to be in the same access domain. These data areas should be private to a thread.
I don't know if this was intended to respond to my concern with custom stack allocators or not. In the systems I know have used this, the memory is not available (mapped dynamically) or known statically (RTEMS runs in virtual address space).
How does this work with custom stack allocators?
The availability of statically initialized threads doesn't mean that everyone has to use them. They are optional. I also have no intention to remove the custom stack allocator. What changes is that the memory area allocated for the stack is used also to contain the thread-local storage and the FP context. These memory areas are private to a thread and non-executable. I really don't know what a potential problem could be with a custom allocator.
I plan to statically initialize the stacks for the idle threads and the MPCI receive server thread. They will reside in special linker sections so that a BSP or application can control the placement in memory.
comment:10 Changed on 01/03/20 at 06:37:06 by Sebastian Huber
Description: | modified (diff) |
---|
comment:12 Changed on 02/12/20 at 15:12:11 by Sebastian Huber <sebastian.huber@…>
In a0211fc9/rtems:
comment:14 Changed on 02/12/20 at 15:12:17 by Sebastian Huber <sebastian.huber@…>
In 0e1ac917/rtems:
comment:16 Changed on 02/12/20 at 15:12:24 by Sebastian Huber <sebastian.huber@…>
In f4dbf37d/rtems:
comment:19 Changed on 02/12/20 at 15:12:34 by Sebastian Huber <sebastian.huber@…>
In 4c9deb6c/rtems:
comment:21 Changed on 02/12/20 at 15:12:40 by Sebastian Huber <sebastian.huber@…>
In 32991495/rtems:
comment:25 Changed on 02/12/20 at 15:12:53 by Sebastian Huber <sebastian.huber@…>
In 8e118f22/rtems:
comment:32 Changed on 02/12/20 at 15:13:16 by Sebastian Huber <sebastian.huber@…>
In d252e20a/rtems:
comment:33 Changed on 02/25/20 at 08:19:35 by Sebastian Huber <sebastian.huber@…>
comment:34 Changed on 02/25/20 at 13:51:04 by Sebastian Huber <sebastian.huber@…>
In 01c97e64/rtems:
comment:35 Changed on 03/05/20 at 14:33:16 by Sebastian Huber <sebastian.huber@…>
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:36 Changed on 06/23/21 at 07:16:03 by Sebastian Huber
Keywords: | qualification added |
---|
comment:37 Changed on 10/14/22 at 09:41:47 by Sebastian Huber <sebastian.huber@…>
In 15bba4ae/rtems:
comment:38 Changed on 10/14/22 at 09:41:49 by Sebastian Huber <sebastian.huber@…>
In 4c89fbcd/rtems:
Does this assume TLS is a fixed size? I would need to revisit how TLS support would be managed in the dynamic loading situation. At a guess I suspect it will break possible soluitons and that concerns me. I would prefer we do not wedged libdl in to a corner with change for a use case I do not fully understand. Maybe a detailed use case would help.