-
Notifications
You must be signed in to change notification settings - Fork 3k
Support thread-safety with ARMC6 #6973
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
Ah! Sorry it was my first time seeing a review request for a group, glad to see that's working now, should help quite a bit with reviews moving forward |
rtos/TARGET_CORTEX/mbed_boot.c
Outdated
#if (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) | ||
|
||
// Check if Kernel has been started | ||
static uint32_t os_kernel_is_active (void) { |
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.
Minor nit: Spacing in this function is inconsistent with the rest of the file (2 spaces versus 4).
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.
@kegilbert I fix spacing in a775f18.
rtos/TARGET_CORTEX/mbed_boot.c
Outdated
// Acquire mutex | ||
__USED void _mutex_acquire(mutex *m) | ||
{ | ||
if (os_kernel_is_active()) { |
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.
Why do we need to check that?
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.
@bulislaw This code is copied from mbed-os/rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_lib.c
. Maybe its original owner could comment it well. I guess it is to guard from e.g. C/C++ initialization code during which kernel is not ready yet.
987d31c
to
a775f18
Compare
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.
Actually why do we need to redefine it? The same functions from rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_lib.c should be used by default
From #6396 (comment), I think the correct solution is to make the versions in rtx_lib.c available on all versions of ARMCC: |
a775f18
to
e442749
Compare
As commented, I force
It seems that with ARMC6 toolchain the |
@ccli8 we've just merged update of RTX could you retest the vanilla version and if it still doesn't work rebase your PR. |
@ccli8, were the __USED _mutex_free(void*);
__WEAK _mutex_free(void *m) {
Blah blah blah
} |
Can we try __WEAK in "Source/rtx_lib.c" definition and __USED in "mbed_boot.c" ? |
@bulislaw Where's vanilla version? |
@geky I've tried it and in the same line. Still meet the multiple definitions link error with ARMC6 toolchain. |
@deepikabhavnani It seems that doesn't make sense. |
@ccli8 The above recommendation was to rebase this one (there is a conflict anyway) to get the latest rtx update , and try it with that one and report back. |
e442749
to
8003834
Compare
I do rebase to fix the conflict (8003834). Just add |
Any update? |
__USED | ||
#endif | ||
__WEAK void _mutex_acquire(mutex *m); | ||
__WEAK __USED void _mutex_acquire(mutex *m); |
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.
used was added to fix this issue ARM-software/CMSIS_5#129. Looking at this, do we still need weak? (the PR referenced at the bottom there, was closed, and RTX_NO_MULTITHREAD_CLIB
was mentioned there).
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.
__WEAK and __USED seems not to make sense if used both. As discussed earlier this function cannot be defined __WEAK because there is already a weak version provided in the C library. Hence the linker cannot distinguish which weak version to use if no non-weak version is given. If its really needed for mbed to get rid of the internal implementation that is part of RTX we need to find a completely different solution.
@ccli8 👍 Thanks for resolving this issue ! /morph build |
Build : SUCCESSBuild number : 2397 Triggering tests/morph test |
@@ -404,6 +404,11 @@ | |||
#define OS_THREAD_LIBSPACE_NUM OS_THREAD_NUM | |||
#endif | |||
|
|||
|
|||
// Don't adopt default multi-thread support for ARM/ARMC6 toolchains from RTX code base. |
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.
We are trying not to change the default config file. Could it be moved to rtos/TARGET_CORTEX/mbed_rtx_conf.h
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.
rtos/TARGET_CORTEX/mbed_boot.c
Outdated
@@ -423,6 +423,60 @@ void __rt_entry (void) { | |||
mbed_start_main(); | |||
} | |||
|
|||
#if defined(RTX_NO_MULTITHREAD_CLIB) |
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.
Could you add a comment saying it was copied from whichever file in rtx.
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.
Exporter Build : SUCCESSBuild number : 2033 |
Test : SUCCESSBuild number : 2184 |
This is to avoid change to RTX code base.
@bulislaw Would you mind re-reviewing? |
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.
Looks awesome!
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.
Looks good to me 👍
/morph build |
Build : SUCCESSBuild number : 2419 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2049 |
Test : SUCCESSBuild number : 2200 |
this patch cause an link error when an application is compiled with |
Seems like a root cause was due to a custom profile without |
Description
This PR tries to add thread-safety support with ARMC6 toolchain.
Related issue
#6396
PelionIoT/mbed-cloud-client-example#11
Pull request type