EnterCriticalSection 如何实现得到锁?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EnterCriticalSection 如何实现得到锁?相关的知识,希望对你有一定的参考价值。

 

[email protected]:
77E022D0 mov edi,edi
77E022D2 push ebp
77E022D3 mov ebp,esp
77E022D5 sub esp,0Ch
77E022D8 push esi
77E022D9 push edi
77E022DA mov edi,dword ptr [ebp+8]
77E022DD lea esi,[edi+4]
77E022E0 mov eax,esi
77E022E2 lock btr dword ptr [eax],0    //原子查看 LockCount 最低位是否为0, 如果为0, 则认为已经得倒
77E022E7 jae [email protected]+1030Bh (77E125DBh)
77E022ED mov eax,dword ptr fs:[00000018h]
77E022F3 mov ecx,dword ptr [eax+24h]
77E022F6 mov dword ptr [edi+0Ch],ecx    //设置OwningThread
77E022F9 mov dword ptr [edi+8],1          //RecursionCount
77E02300 pop edi
77E02301 xor eax,eax
77E02303 pop esi
77E02304 mov esp,ebp
77E02306 pop ebp
77E02307 ret 4

以上是关于EnterCriticalSection 如何实现得到锁?的主要内容,如果未能解决你的问题,请参考以下文章

关于EnterCriticalSection()(转)

InterlockedIncrement 与 EnterCriticalSection/counter++/LeaveCriticalSection

Windows API一日一练 46 EnterCriticalSection和LeaveCriticalSection

C++11多线程 互斥量与Windows临界区

015 临界区

双重检查锁定的正确编译器内在函数?