IDLE Stacks Not Allocated via User Provided Stack Allocator

Joel Sherrill joel at rtems.org
Thu Sep 30 16:19:05 UTC 2021


On Thu, Sep 30, 2021 at 12:39 AM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> On 30/09/2021 00:43, Joel Sherrill wrote:
> > Hi
> >
> > In Feb 2020, idle thread stack memory was changed to be statically
> > allocated which is good for most RTEMS deployments. However, it is
> > broken when you REALLY need it to be allocated by the plugin stack
> > allocator.
> >
> > The paravirtualized environment that tripped over this provides stack
> > memory protection. A special area of memory is reserved for stacks and
> > the processor and host OS enforce that the stack pointer is always
> > within the reserved memory segment. This was possible prior to 5
> > branching which is what the current RTEMS support for that environment
> > is based on.
>
> Is the memory area known at link time? In this case you can use the
> linker script to place the idle stacks in this area. The idle stacks are
> allocated in a special section:
>
> RTEMS_SECTION( ".rtemsstack.idle" )

That's a good idea and I investigated it. It might work in some setups but
not this one. This environment have multiple "processes" (not POSIX
processes but concurrent entities with properties) and there might be
multiple in the "container". RTEMS applications run in one of the processes
and there can be multiple containers with RTEMS applications.

During initialization, the BSP makes a system call to determine
various characteristics of the container and one of those is to get
our stack memory address and size.

Even if this worked, I felt like I would implement the idle thread stack
allocator hook because it is generally needed. But this is the solution
I'm going to have to use.

>
> >
> > The code which needs adjusting is a combination of threadcreateidle.c
> > and confdefs/percpu.h which reserves the memory. My current thinking
> > is to add another stack allocator hook for the idle stacks and have it
> > default to a method which does the current mechanism. This default
> > method would be defines in percpu.h and instantiated unless the user
> > configures another method.
>
> Yes, this sounds like a good approach if the memory needs to be
> allocated a run-time. We only need an allocator hook. Initialization of
> the allocator can be done via a system initialization handler.

Why not statically like the other stack allocator parameters and hooks?

> Deallocation is not needed. The allocator hook should have parameters
> for the idle task stack size and the idle task index.

This matches my thinking.

Thanks.

--joel

> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.huber at embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list