-
Notifications
You must be signed in to change notification settings - Fork 3k
Boot: Make ARMC library mutexes dynamic #4731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/morph test-nightly |
rtos/mbed_boot.c
Outdated
attr.name = "ARMC toolchain mutex"; | ||
attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust; | ||
|
||
*m = osMutexNew(&attr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if osMutexNew succeeds, then you have 2 calls to osMutexNew(&attr)
one here and another one below.
so you have *m overridden with another allocation and previous one leaks
is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it succeeds it returns. See the 2 following lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it succeeds it returns. See the 2 following lines.
@avolinski Does that answer your questions?
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputExample Build failed! |
/morph test-nightly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
rtos/mbed_boot.c
Outdated
{ | ||
osMutexAttr_t attr; | ||
memset(&attr, 0, sizeof(attr)); | ||
attr.name = "ARMC toolchain mutex"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARMCC should be the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARM toolchain or ARMCx
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputExample Build failed! |
533adae
to
a2af318
Compare
It crashed due to some Jenkins job, test needs re-running.
|
retest uvisor |
a2af318
to
8e8d68e
Compare
Looking at this again it seems that this could be simplified to not use a combination of pool + heap and just used all heap. Why are we not doing that? |
ARM toolchain requires a mutex to use malloc. To boot platform to main you require 5 mutexes, therefore I decided we may as well have a pool of 5. |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Something still doesn't sit right here. After reading the manual it seems the static mutexes still doesn't guarantee that malloc will use a statically allocated slot therefore the call to malloc could be unprotected. The safest approach seems to be all dynamic mutexes and adding a call to malloc during startup within a critical section at startup before the kernel is running. |
It all happens before the kernel is running, but call to malloc requires a mutex, so fully dynamic solution would get as to malloc->mutex_initialize()->malloc()->mutex_initialize(). |
@sg- I've got a reply from ARM toolchain team, there's a maximum of 8 mutexes + 1 mutex for each fopen. And it's not guaranteed to stay like that between version, but it didn't change for a long time. They advised that our hybrid solution should do the trick. Do you want me to change the number of static pool to 8? |
That would be great - even better if there is a documentation link to go with the commit message but OK if that doesn't exist. |
It's not documented, they had to grep the code and figure out where mutex ops are called. |
Thanks for sharing, +1 to have it set to 8 then |
ARM toolchain requires variable number of dynamic mutexes. We use combination of RTX mutex pool and heap allocation to achieve that.
8e8d68e
to
a1736e6
Compare
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
ARMC requires variable number of dynamic mutexes. We use combination of RTX mutex pool and heap allocation to achieve that.
Status
READY
CC: @0x6d61726b @c1728p9
Closes #4688