This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CMSIS KEIL RTOS - Using protected global structure vs Memory pool usage

Dear all,

I am using Keil 5.16 and CMSIS Keil RTX RTOS. I am analysing my design scenario in which I need to share a data structure between two threads created using osThreadCreate(). One thread will be writing to this data structure. Another thread will be reading from this data structure. Reading/writing can happen simultaneously. I understood there are two possibilities.

One option is to maintain a global structure and both threads read/write to this structure by protecting using a mutex.

Another option is to maintain the structure within a memory pool created and both threads read/write to this pool protected using a mutex.

Can anyone tell me which is the effective solution? As all the threads run in the same address space, theoretically I didn't feel any difference if it is a global data structure or is maintained in a pool.. Can you share your thoughts on this?

Thank you,
Lullaby Dayal

Parents
  • Thank you for your reply.

    I don't see a use of a pool unless you need to release the memory or have multiple thread pairs where each thread pair should agree of a unique pool entry.

    Understood the usage of a pool for the case of dynamic memory allocation / de-allocation.
    What you meant by multiple thread pairs using a unique pool entry? Did you mean if there are more than two threads sharing a global resource, it would be effective to keep that in a protected shared memory pool?

    Could you please shed some light to this concern?

    Thank you,
    Lullaby

Reply
  • Thank you for your reply.

    I don't see a use of a pool unless you need to release the memory or have multiple thread pairs where each thread pair should agree of a unique pool entry.

    Understood the usage of a pool for the case of dynamic memory allocation / de-allocation.
    What you meant by multiple thread pairs using a unique pool entry? Did you mean if there are more than two threads sharing a global resource, it would be effective to keep that in a protected shared memory pool?

    Could you please shed some light to this concern?

    Thank you,
    Lullaby

Children