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

Implementing mutex locking of the C-libary

Hello all,

I want to use dynamic memory allocation functions of the Realview C-Libary(MDK-ARM V3.11) together with the RTX-Kernel in a multithreaded application.

To make some functions threadsafe I will have to implement the mutex functions of the libary. Because the mutexes of the RTX-Kernel are larger than a 32-Bit Word, I have to define those as global variables and use the 32-Bit Word as pointer.

Now I needed to now how many mutexes are used by the C-Libary to reserve enough memory at compiletime. I couldn't find any information about that in the documentation of the libary. So I made some tests and recognized that the mutex_initialize function was called 5 times at the startup. So I assume that only 5 mutexes are necessary.

Is the number of neccessary mutexes constant or does it depent on the functions used?

I would be greatful for some hints.

Thanks in advance

Rainer

Parents
  • No, It appears as though I never read that section (It is nice when you learn something new). It does appear as though you are on the right track re-implementing these 3 functions. I do not have the answer to what I believe the original question was, which was "how many mutexes do you need". Depending on how separate the C library functions are, you may be able to count the references to _mutex_initialize in the map file to determine how many you need, then again, maybe not. Sorry for any mis-information I have given you.

    (note - you could use only 1 mutex object, returning this same on on each _mutex_initialize [make sure you only initialize the mutex once, not each time _mutex_initialize is called], this limits the number of mutexes that you need, with the draw back of not allowing more than 1 task to be in ANY mutexed section at the same time)

Reply
  • No, It appears as though I never read that section (It is nice when you learn something new). It does appear as though you are on the right track re-implementing these 3 functions. I do not have the answer to what I believe the original question was, which was "how many mutexes do you need". Depending on how separate the C library functions are, you may be able to count the references to _mutex_initialize in the map file to determine how many you need, then again, maybe not. Sorry for any mis-information I have given you.

    (note - you could use only 1 mutex object, returning this same on on each _mutex_initialize [make sure you only initialize the mutex once, not each time _mutex_initialize is called], this limits the number of mutexes that you need, with the draw back of not allowing more than 1 task to be in ANY mutexed section at the same time)

Children
No data