??Windows????????С?????????μ???????
???????????? ???????[ 2012/10/17 10:55:12 ] ????????
????????????????????????
Long a;
DWORD WINAPI ThreadFunc2(PVOID pvParam)
{
InterlockedExchangeAdd(&a??1);
Return 0;
}
??????????????????a???????????????????С????????a???????2???????????????????????1????????????InterlockedIncrement??????
??????ЩInterlock??к???????????????????????е?cpu?????????x86???????Interlock?????????????????????????????????????????cpu???????????????
?????????????????Interlock????????ι????????????????????????????????????????cpu????Щ??????????????????????????????е??
????Interlock??к???????????????????????cpu????????????????????????????????л???
?????????Щ???????????????????????????ɡ?
???????????????????б???????????????
LONG InterlockedExchange(
PLONG volatile plTarget??
LONG lValue);
LONGLONG InterlockedExchange64(
PLONGLONG volatile plTarget??
LONGLONG lValue);
PVOID InterlockedPointer(
PVOID *volatile ppvTarget??
PVOID pvValue);
????InterloackedExchange??InterlockedExchangePointer???????????????????????????????????滻????????????????
????????32λ??ó????????????????滻??32λ???????????64λ????ó???InterlockedExchangePointer???滻??64λ?????????????????64λ???
?????????????????????????????????????????InterlockedExchange??????????á?
Bool use=false;
Void func()
{
While(InterlockedExchange(&use??true)==true)
Sleep(0);
//........
InterlockedExchange(&use??false);
}
????While??????????У???use??????true???????????????true????????????false????????????δ????á???????????????С????????????true???????????????????????????????sleep????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11