-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Why nuttx didn't support atomic instruction? #10642
Comments
atomic operation is defined since c11(https://en.cppreference.com/w/c/language/atomic), and the implementation is provided by toolchain already(e.g, libgcc.a from gcc). That's why you can't find the implementation from nuttx, an atmic test was added recently to help you check the atomic support with your toolchain: |
First thank you for your reply. https://github.com/apache/nuttx/blob/master/libs/libc/machine/arch_atomic.c |
yes here atomic are builtin with a spin lock ... where you want to build your spin lock relaying on atomic ops ehehe ; gcc and clang have builtin atomic ops, however for gcc not prior 4.7, have a look here, that's pasta dig up (1), you may still dump assembly and see how barriers are emitted, moslty spin lock only need safe write, read so a compare_swap op. -1 |
Since the code can just disable the current core interrupt, not other cores. Even it can disable other cores, it doesn't work as your expect, because other cores are still running and may try to acquire the same lock. |
Yes, It acquire same lock and spin here. |
Many architecture offer atomic instruction like compare and swap, test and set....
But I didn't find any atomic operation in nuttx kernel except atomic testing.
Is there any reason so we don't use them?
Because recently I want to optimize fair spinlock #10605 with lock-free skill.
But the basic requirements are atomic instruction.
The text was updated successfully, but these errors were encountered: