Callback from residential portion to ThreadX module with synchronous result

HugPeter-9392 246 Reputation points
2023-03-15T17:07:29.47+00:00

Hello

This is a follow-up request to https://video2.skills-academy.com/en-us/answers/questions/1185090/callback-from-residential-portion-to-threadx-modul. I was asked to clarify related questions.

We still have the situation that a third library within the residential application has a callback. The library callback needs frequent access to data/functionality only available in a ThreadX module. The callback needs to return to the library with information requested from within the ThreadX module. In other words the library needs to synchronously call into the ThreadX module.

I could verify that the function pointer approach work when both residential application and ThreadX module use absolute positioning.

Question 1: Can you confirm that the function pointer approach is a good and safe solution as long as residential application and ThreadX module use absolute positioning? What are the limitations of this approach?

Question 2: Can you confirm that when one of residential application and ThreadX module do not make use of absolute positioning, the solution is uncertain. Such an approach is not advisable for a new development.

Question 3: Can you explain the event flags approach in more detail? In my understanding event flags are for asynchronous event passing. But we need a synchronous return of the callback.

Question 4: Are there dependencies to the used compilers?

Question 5: Are there dependencies to the used C or C++ version?

At the moment we are free to architect the communication between residential code and module.

Thanks for support.

Peter

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
331 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. QuantumCache 20,266 Reputation points
    2023-03-20T18:39:40.31+00:00

    Hello @HugPeter-9392

    I will try to help as much as possible from my side, meanwhile SME on this topic respond to your queries!

    Question 1: Can you confirm that the function pointer approach is a good and safe solution as long as residential application and ThreadX module use absolute positioning? What are the limitations of this approach?

    Idea is good, it may not be portable across different platforms or architectures, as the memory layout may differ. For example, it can be difficult to debug and maintain the code when using function pointers, the function must be accessible from the residential application. More

    Question 2: Can you confirm that when one of residential application and ThreadX module do not make use of absolute positioning, the solution is uncertain. Such an approach is not advisable for a new development.

    This can lead to issues with memory alignment and address translation. Not advisable for new development. It is advisable to use a more robust approach such as message passing or shared memory.

    Question 3: Can you explain the event flags approach in more detail? In my understanding event flags are for asynchronous event passing. But we need a synchronous return of the callback.

    You can use event flags to signal the ThreadX module that the callback has been called and to wait for the ThreadX module to return the requested information.

    0 comments No comments

  2. HugPeter-9392 246 Reputation points
    2023-03-20T18:39:52.1466667+00:00

    Follow up to question 1: Can you confirm, that the function pointer approach is advisable, as long as the code runs on a Cortex-M uC and memory access is granted? E.g. no MPU that forbids memory access.

    Edit 2023-03-29

    Yesterday I was asked to further clarify possible sources for portability issues. Is it only bound to accessibility of code and data memory in terms of access rights like MPU or memory attributes. Or are there other things like calling conventions, compiler/linker code optimizations, non-linear memory layouts (non continuous address ranges), CPU architecture related topics, others?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.