Skip to content

Name the memory section of stack and TCB of timer task - #798

Closed
aymenjebalibmw wants to merge 1 commit into
eclipse-threadx:masterfrom
aymenjebalibmw:protect_timer_task-1
Closed

aymenjebalibmw wants to merge 1 commit into
eclipse-threadx:masterfrom
aymenjebalibmw:protect_timer_task-1

Conversation

@aymenjebalibmw

Copy link
Copy Markdown

This allows to link the named memory section to a dedicated partition of the RAM. For example for performance reasons, we can link the stack region into a low latency RAM memory. This feature is also useful to protect Task Stacks from overflowing each others, considering that we protect by MPU each stack.

PR checklist

  • Updated function header with a short description and version number
  • Added test case for bug fix or new feature
  • Validated on real hardware

This allows to link the named memory section to a dedicated
partition of the RAM. For example for performance reasons, we
can link the stack region into a low latency RAM memory.
This feature is also useful to protect Task Stacks from overflowing
each others, considering that we protect by MPU each stack.
@blanchardj-dev

Copy link
Copy Markdown

This would introduce compiler dependent code into the code ThreadX sources. Wouldn't it be better to perform the placement directly in the linker script instead?

@aymenjebalibmw

Copy link
Copy Markdown
Author

This would introduce compiler dependent code into the code ThreadX sources. Wouldn't it be better to perform the placement directly in the linker script instead?

Linker regular expression on LLVM didn't work to catch the required symbol.

I can change it to something like this, so in tx_user.h the proper compiler pragma/attribute can be specified:

tx_timer_thread_stack_area[(((UINT) TX_TIMER_THREAD_STACK_SIZE)+((sizeof(ULONG))- ((UINT) 1)))/(sizeof(ULONG))] TX_TIMER_STACK_SECTION_NAME;

@blanchardj-dev

Copy link
Copy Markdown

You might need to compile with the -fdata-sections flags to get each symbol into a different section. Then, I think you should be able to isolate it directly in the linker script.

As for the section name macro this would not be fully portable sadly since some compilers using pragmas instead of variable attributes require the pragma to be before the symbol definition.

@aymenjebalibmw

Copy link
Copy Markdown
Author

You might need to compile with the -fdata-sections flags to get each symbol into a different section. Then, I think you should be able to isolate it directly in the linker script.

As for the section name macro this would not be fully portable sadly since some compilers using pragmas instead of variable attributes require the pragma to be before the symbol definition.

yes we do use -fdata-sections, my bad now re-ordering the linker script we catch this properly.
thanks for the advice.

@aymenjebalibmw

Copy link
Copy Markdown
Author

not needed,

@aymenjebalibmw

aymenjebalibmw commented Oct 6, 2026 •

Copy link
Copy Markdown
Author

Shit!!! closing was too quick. there is no way arround the named memory section for the feature I need.
Otherwise I will mess up the linker script.

The issue as afollowing, we would like to have contiguous address space with no gaps for the TCBs and place them into one unique MPU region, the stacks are all together inside one other region.
now If I don't have named sections, I will have to catch symbol by symbol in the linker, that is not maintainable if add more tasks. meaning that I need to catch all stacks and then all TCBs and If I want to place these at the end of the memory, I will have to partition the RAM memory to even smaller chuncks and fill with the size manually.
Whille all can be resolved with named sections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants