You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicclassAtomicIntegerextendsNumberimplementsjava.io.Serializable {
privatestaticfinallongserialVersionUID = 6214790243416807050L;
/* * This class intended to be implemented using VarHandles, but there * are unresolved cyclic startup dependencies. */privatestaticfinalUnsafeU = Unsafe.getUnsafe();
privatestaticfinallongVALUE
= U.objectFieldOffset(AtomicInteger.class, "value");
privatevolatileintvalue;
/** * Atomically updates Java variable to {@code x} if it is currently * holding {@code expected}. * * <p>This operation has memory semantics of a {@code volatile} read * and write. Corresponds to C11 atomic_compare_exchange_strong. * * @return {@code true} if successful */@IntrinsicCandidatepublicfinalnativebooleancompareAndSetInt(Objecto, longoffset,
intexpected,
intx);
cas 연산후 +1을 왜 더할까? => c에서 원자적으로 값을 set하고 native 메서드 이후는 jvm에서 delta를 합침(메모리에는 이미 변경되어있음. jvm에 있는 값을 변경하는 것)
->
atomic_compare_exchange_strong
windows 커널...(소스제공안함..)
interlockedcompareexchange
linux로 변경
linux kernal arm asm cas 발견 - sh란 cpu
(참고 sh ,슈퍼H)
x86으로 다시 찾아보기
cpu assembly
=> x86 CMPXCHG8B Operation 부분 참조
흐름
The text was updated successfully, but these errors were encountered: