-
Notifications
You must be signed in to change notification settings - Fork 149
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
XrdCl: Provide atomicity for PostMaster value using built-in functions #266
XrdCl: Provide atomicity for PostMaster value using built-in functions #266
Conversation
You don't see the difference because you have used a 32-bit integer in your test case... |
I also think that you will see a difference between |
For x86_64 the assembler code is the same for both int and long long/int64_t. The details on
And it's not in the XrdSysAtomics.hh header file. I tried to stick to what was available there. |
void *a = malloc(10); Results with: movl $10, %edi
call malloc
movq %rax, -8(%rbp) void *a = 0;
__sync_bool_compare_and_swap(&a, 0, malloc(10)); Results with: movl $10, %edi
call malloc
movq %rax, %rdx
movl $0, %eax
lock cmpxchgq %rdx, -8(%rbp) void *a = 0;
__sync_lock_test_and_set(&a, malloc(10)); Results with: movq $0, -8(%rbp)
movl $10, %edi
call malloc
xchgq -8(%rbp), %rax The |
For ARM both |
Yes, I know it’s not there. I have a new XrdSysAtomics.hh that adds. It also transparently supports C11, gcc __atomic_xxx(), and __sync_xxx() operations, depending on what is available. I am waiting for 4.2 to come out before pushing it in. Andy From: Elvin Sindrilaru For x86_64 the assembler code is the same for both int and long long/int64_t. The details on __sync_lock_test_and_set don't seem too reassuring when it comes to support for this. type __sync_lock_test_and_set (type *ptr, type value, ...) Many targets have only minimal support for such locks, and do not support a full This builtin is not a full barrier, but rather an acquire barrier. This means that — Use REPLY-ALL to reply to list To unsubscribe from the XROOTD-DEV list, click the following link: |
c510451
to
106165d
Compare
106165d
to
b38e60c
Compare
Updated pull request to follow the naming conventions. |
XrdCl: Provide atomicity for PostMaster value using built-in functions
This uses the built-in atomic functions. The test program is:
The assembler code for x86_64 is as expected:
While for ARM it looks like this:
So, the conclusion is that for x86_64 there is no difference whether we use or not
__sync_fetch*
. Obviously this also works without c++11. Let me know which one you prefer between this one and #265.