هل OsCompareAnswap (Mac OS X) يعادل CMPXCHG8B؟
-
21-09-2019 - |
سؤال
هل OsCompareAnswap (Mac OS X) يعادل CMPXCHG8B؟
المحلول
يمكنك العثور على تعريف الوظائف الذرية في ملف osatomic.s في مصدر XNU. على سبيل المثال ، إليك OsatoMicCompareAndswapptr لـ x86_64 في الإصدار 1486.2.11:
_OSCompareAndSwap64:
_OSCompareAndSwapPtr: #;oldValue, newValue, ptr
movq %rdi, %rax
lock
cmpxchgq %rsi, 0(%rdx) #; CAS (eax is an implicit operand)
sete %al #; did CAS succeed? (TZ=1)
movzbq %al, %rax #; clear out the high bytes
ret
نصائح أخرى
قفل CMPXCHG8B
أكثر تحديدا
إنه مخصص لمعالجات Intel ، ولكن يأخذ في الاعتبار ، أن OSX لا يوجد ليس فقط لهندسة Intel ، لذلك سيكون ASM مختلفًا
لا تنتمي إلى StackOverflow