هل OsCompareAnswap محصن ضد مشكلة ABA مثل CMPXCHG8B؟
-
21-09-2019 - |
سؤال
هل OsCompareAnswap محصن ضد ABA مشكلة مثل CMPXCHG8B؟
المحلول
كل هذا يتوقف على التنفيذ. OsCompareAnswap* ليست سوى واجهة تضمن مشغل CAS ذري (إذا كانت وحدة المعالجة المركزية تدعمها).
ل x86 يتم تنفيذ هذه الوظيفة لـ 64 بت كـ
_OSCompareAndSwap64:
pushl %edi
pushl %ebx
movl 4+8(%esp), %eax #; low 32-bits of oldValue
movl 8+8(%esp), %edx #; high 32-bits of oldValue
movl 12+8(%esp), %ebx #; low 32-bits of newValue
movl 16+8(%esp), %ecx #; high 32-bits of newValue
movl 20+8(%esp), %edi #; ptr
lock
cmpxchg8b 0(%edi) #; CAS (eax:edx, ebx:ecx implicit)
sete %al #; did CAS succeed? (TZ=1)
movzbl %al, %eax #; clear out the high bytes
popl %ebx
popl %edi
ret
لذا فإن الجواب لك ربما هو "نعم".
لا تنتمي إلى StackOverflow