青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

CriticalSection的ASM原代碼

        title   "Critical Section Support"
;
++
;
;  Copyright (c) 
1991  Microsoft Corporation
;
;  Module Name:
;
;     critsect.asm
;
;  Abstract:
;
;     This module implements functions to support user mode critical sections.
;
;  Author:
;
;     Bryan M. Willman (bryanwi) 
2-Oct-91
;
;  Environment:
;
;     Any mode.
;
;  Revision History:
;
;
--

.486p
        .xlist
include ks386.inc
include callconv.inc                    ; calling convention macros
include mac386.inc
        .list

_DATA   SEGMENT DWORD PUBLIC 
'DATA'
    
public _LdrpLockPrefixTable
_LdrpLockPrefixTable    label dword
        dd offset FLAT:Lock1
        dd offset FLAT:Lock2
        dd offset FLAT:Lock3
        dd offset FLAT:Lock4
        dd offset FLAT:Lock5
        dd offset FLAT:Lock6
        dd offset FLAT:Lock7
        dd 
0
_DATA   ENDS

_TEXT   SEGMENT PARA PUBLIC 
'CODE'
        ASSUME  DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING

        EXTRNP  _RtlpWaitForCriticalSection,
1
        EXTRNP  _RtlpUnWaitCriticalSection,
1
if DEVL
        EXTRNP  _RtlpNotOwnerCriticalSection,
1
endif
if DBG
        EXTRNP  _RtlpCriticalSectionIsOwned,
1
endif

CriticalSection equ     [esp 
+ 4]

        page , 
132
        subttl  
"RtlEnterCriticalSection"

;
++
;
; NTSTATUS
; RtlEnterCriticalSection(
;    IN PRTL_CRITICAL_SECTION CriticalSection
;    )
;
; Routine Description:
;
;    This function enters a critical section.
;
; Arguments:
;
;    CriticalSection 
- supplies a pointer to a critical section.
;
; Return Value:
;
;   STATUS_SUCCESS or raises an exception 
if an error occured.
;
;
--

        align   
16
cPublicProc _RtlEnterCriticalSection,
1
cPublicFpo 
1,0

        mov     ecx,fs:PcTeb            ; 
get current TEB address
        mov     edx,CriticalSection     ; 
get address of critical section
        cmp     CsSpinCount[edx],
0      ; check if spin count is zero
        jne     
short Ent40             ; if ne, spin count specified

;
; Attempt to acquire critical section.
;

Lock1:                                  ;
   
lock inc     dword ptr CsLockCount[edx] ; increment lock count
        jnz     
short Ent20             ; if nz, already owned

;
; Set critical section owner and initialize recursion count.
;

Ent10:
if DBG
        cmp     CsOwningThread[edx],
0
        je      @F
        stdCall _RtlpCriticalSectionIsOwned, 
<edx>
        mov     ecx,fs:PcTeb            ; 
get current TEB address
        mov     edx,CriticalSection     ; 
get address of critical section
@@:
endif ; DBG
        mov     eax,TbClientId 
+ 4[ecx] ; get current client ID
        mov     CsOwningThread[edx],eax ; 
set critical section owner
        mov     dword ptr CsRecursionCount[edx],
1 ; set recursion count

if DBG

        inc     dword ptr TbCountOfOwnedCriticalSections[ecx] ; increment owned count
        mov     eax,CsDebugInfo[edx]    ; 
get debug information address
        inc     dword ptr CsEntryCount[eax] ; increment entry count

endif ; DBG

        xor     eax,eax                 ; 
set success status

        stdRET  _RtlEnterCriticalSection

;
; The critical section 
is already owned, but may be owned by the current thread.
;

        align   
16
Ent20:  mov     eax,TbClientId 
+ 4[ecx] ; get current client ID
        cmp     CsOwningThread[edx],eax ; check 
if current thread is owner
        jne     
short Ent30             ; if ne, current thread not owner
        inc     dword ptr CsRecursionCount[edx] ; increment recursion count

if DBG

        mov     eax,CsDebugInfo[edx]    ; 
get debug information address
        inc     dword ptr CsEntryCount[eax] ; increment entry count

endif ; DBG

        xor     eax,eax                 ; 
set success status

        stdRET  _RtlEnterCriticalSection

;
; The critcal section 
is owned by another thread and the current thread must
; wait 
for ownership.
;

Ent30:  stdCall _RtlpWaitForCriticalSection, 
<edx> ; wait for ownership
        mov     ecx,fs:PcTeb            ; 
get current TEB address
        mov     edx,CriticalSection     ; 
get address of critical section
        jmp     Ent10                   ; 
set owner and recursion count

;
; A nonzero spin count 
is specified.
;

        align   
16
Ent40:  mov     eax,TbClientId 
+ 4[ecx] ; get current client ID
        cmp     CsOwningThread[edx],eax ; check 
if current thread is owner
        jne     
short Ent50             ; if ne, current thread not owner

;
; The critical section 
is owned by the current thread. Increment the lock
; count and the recursion count.
;

Lock6:                                  ;
   
lock inc     dword ptr CsLockCount[edx] ; increment lock count
        inc     dword ptr CsRecursionCount[edx] ; increment recursion count

if DBG

        mov     eax,CsDebugInfo[edx]    ; 
get debug information address
        inc     dword ptr CsEntryCount[eax] ; increment entry count

endif ; DBG

        xor     eax,eax                 ; 
set success status

        stdRET  _RtlEnterCriticalSection

;
; A nonzero spin count 
is specified and the current thread is not the owner.
;

        align   
16
Ent50:  push    CsSpinCount[edx]        ; 
get spin count value
Ent60:  mov     eax,
-1                  ; set comparand value
        mov     ecx,
0                   ; set exchange value

Lock7:
   
lock cmpxchg dword ptr CsLockCount[edx],ecx ; attempt to acquire critical section
        jnz     
short Ent70             ; if nz, critical section not acquired

;
; The critical section has been acquired. Set the owning thread and the initial
; recursion count.
;

        add     esp,
4                   ; remove spin count from stack
        mov     ecx,fs:PcTeb            ; 
get current TEB address
        mov     eax,TbClientId 
+ 4[ecx] ; get current client ID
        mov     CsOwningThread[edx],eax ; 
set critical section owner
        mov     dword ptr CsRecursionCount[edx],
1 ; set recursion count

if DBG

        inc     dword ptr TbCountOfOwnedCriticalSections[ecx] ; increment owned count
        mov     eax,CsDebugInfo[edx]    ; 
get debug information address
        inc     dword ptr CsEntryCount[eax] ; increment entry count

endif ; DBG

        xor     eax,eax                 ; 
set success status

        stdRET  _RtlEnterCriticalSection

;
; The critical section 
is currently owned. Spin until it is either unowned
; or the spin count has reached zero.
;
; If waiters are present, don
't spin on the lock since we will never see it go free
;

Ent70:  cmp     CsLockCount[edx],
1      ; check if waiters are present,
        jge     
short Ent76             ; if ge 1, then do not spin

Ent75:  YIELD
        cmp     CsLockCount[edx],
-1     ; check if lock is owned
        je      
short Ent60             ; if e, lock is not owned
        dec     dword ptr [esp]         ; decrement spin count
        jnz     
short Ent75             ; if nz, continue spinning
Ent76:  add     esp,
4                   ; remove spin count from stack
        mov     ecx,fs:PcTeb            ; 
get current TEB address
        jmp     Lock1                   ;

stdENDP _RtlEnterCriticalSection

        page , 
132
        subttl  
"RtlLeaveCriticalSection"
;
++
;
; NTSTATUS
; RtlLeaveCriticalSection(
;    IN PRTL_CRITICAL_SECTION CriticalSection
;    )
;
; Routine Description:
;
;    This function leaves a critical section.
;
; Arguments:
;
;    CriticalSection 
- supplies a pointer to a critical section.
;
; Return Value:
;
;   STATUS_SUCCESS or raises an exception 
if an error occured.
;
;
--

        align   
16
cPublicProc _RtlLeaveCriticalSection,
1
cPublicFpo 
1,0

        mov     edx,CriticalSection
if DBG
        mov     ecx,fs:PcTeb                ; (ecx) 
== NtCurrentTeb()
        mov     eax,TbClientId
+4[ecx]       ; (eax) == NtCurrentTeb()->ClientId.UniqueThread
        cmp     eax,CsOwningThread[edx]
        je      @F
        stdCall _RtlpNotOwnerCriticalSection, 
<edx>
        mov     eax,STATUS_INVALID_OWNER
        stdRET  _RtlLeaveCriticalSection
@@:
endif ; DBG
        xor     eax,eax                     ; Assume STATUS_SUCCESS
        dec     dword ptr CsRecursionCount[edx]
        jnz     leave_recurs                ; skip 
if only leaving recursion

        mov     CsOwningThread[edx],eax     ; clear owning thread id

if DBG
        mov     ecx,fs:PcTeb                ; (ecx) 
== NtCurrentTeb()
        dec     dword ptr TbCountOfOwnedCriticalSections[ecx]
endif ; DBG

Lock2:
   
lock dec     dword ptr CsLockCount[edx]  ; interlocked dec of
                                            ;  CriticalSection
->LockCount
        jge     @F
        stdRET  _RtlLeaveCriticalSection

@@:
        stdCall _RtlpUnWaitCriticalSection, 
<edx>
        xor     eax,eax                     ; 
return STATUS_SUCCESS
        stdRET  _RtlLeaveCriticalSection

        align   
16
leave_recurs:
Lock3:
   
lock dec     dword ptr CsLockCount[edx]  ; interlocked dec of
                                            ;  CriticalSection
->LockCount
        stdRET  _RtlLeaveCriticalSection

_RtlLeaveCriticalSection    endp

        page    ,
132
        subttl  
"RtlTryEnterCriticalSection"
;
++
;
; BOOL
; RtlTryEnterCriticalSection(
;    IN PRTL_CRITICAL_SECTION CriticalSection
;    )
;
; Routine Description:
;
;    This function attempts to enter a critical section without blocking.
;
; Arguments:
;
;    CriticalSection (a0) 
- Supplies a pointer to a critical section.
;
; Return Value:
;
;    If the critical section was successfully entered, then a value of TRUE
;    
is returned as the function value. Otherwise, a value of FALSE is returned.
;
;
--

CriticalSection equ     [esp 
+ 4]

cPublicProc _RtlTryEnterCriticalSection,
1
cPublicFpo 
1,0

        mov     ecx,CriticalSection         ; interlocked inc of
        mov     eax, 
-1                     ; set value to compare against
        mov     edx, 
0                      ; set value to set
Lock4:
   
lock cmpxchg dword ptr CsLockCount[ecx],edx  ; Attempt to acquire critsect
        jnz     
short tec10                 ; if nz, critsect already owned

        mov     eax,fs:TbClientId
+4         ; (eax) == NtCurrentTeb()->ClientId.UniqueThread
        mov     CsOwningThread[ecx],eax
        mov     dword ptr CsRecursionCount[ecx],
1

if DBG
        mov     eax,fs:PcTeb                ; (ecx) 
== NtCurrentTeb()
        inc     dword ptr TbCountOfOwnedCriticalSections[eax]
endif ; DBG

        mov     eax, 
1                      ; set successful status

        stdRET  _RtlTryEnterCriticalSection

tec10:
;
; The critical section 
is already owned. If it is owned by another thread,
return FALSE immediately. If it is owned by this thread, we must increment
; the 
lock count here.
;
        mov     eax, fs:TbClientId
+4        ; (eax) == NtCurrentTeb()->ClientId.UniqueThread
        cmp     CsOwningThread[ecx], eax
        jz      tec20                       ; 
if eq, this thread is already the owner
        xor     eax, eax                    ; 
set failure status
        YIELD
        stdRET  _RtlTryEnterCriticalSection

tec20:
;
; This thread 
is already the owner of the critical section. Perform an atomic
; increment of the LockCount and a normal increment of the RecursionCount and
return success.
;
Lock5:
   
lock inc     dword ptr CsLockCount[ecx]
        inc     dword ptr CsRecursionCount[ecx]
        mov     eax, 
1
        stdRET  _RtlTryEnterCriticalSection

stdENDP _RtlTryEnterCriticalSection


_TEXT   ends
        end


posted on 2008-01-25 11:17 楊粼波 閱讀(921) 評論(2)  編輯 收藏 引用

評論

# re: CriticalSection的ASM原代碼 2015-11-11 17:07 xmpdhml

一點小建議:代碼尤其是匯編代碼設置成等寬字體可能更容易閱讀。  回復  更多評論   

# re: CriticalSection的ASM原代碼 2015-11-12 09:54 楊粼波

@ xmpdhml
如果你本機不支持等寬字體,那也是白瞎。
  回復  更多評論   

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲美女精品一区| 日韩午夜在线播放| 欧美电影免费观看大全| 久久夜色精品国产| 另类成人小视频在线| 久久人人爽爽爽人久久久| 久热精品在线视频| 欧美精品一线| 国产精品一区二区在线观看| 国产亚洲成av人在线观看导航 | 欧美精品在线极品| 欧美三级日本三级少妇99| 国产精品日韩精品欧美精品| 国产日韩视频| 亚洲乱码精品一二三四区日韩在线| 亚洲精品色图| 欧美在线黄色| 亚洲国产精品va在线看黑人| 亚洲最新在线视频| 久久成人精品一区二区三区| 欧美第一黄网免费网站| 国产精品亚洲аv天堂网| 在线观看欧美视频| 亚洲一区二区在线免费观看视频 | 午夜欧美不卡精品aaaaa| 免费日韩成人| 亚洲永久免费观看| 欧美成人蜜桃| 狠狠色狠狠色综合日日小说| 亚洲一区黄色| 亚洲国产另类精品专区| 亚洲一区二区三区四区五区午夜 | 亚洲免费视频在线观看| 久久国产一二区| 亚洲人成人99网站| 久久久免费精品视频| 国产精品狠色婷| 亚洲高清在线观看一区| 亚洲免费视频在线观看| 亚洲激情自拍| 母乳一区在线观看| 韩国精品一区二区三区| 亚洲欧美三级伦理| 亚洲毛片一区二区| 欧美搞黄网站| 亚洲人屁股眼子交8| 麻豆国产精品va在线观看不卡| 一本色道久久综合亚洲精品不 | 欧美肥婆在线| 亚洲电影免费观看高清完整版在线观看 | 免费观看日韩av| 国内揄拍国内精品久久| 欧美中文在线观看| 亚洲欧美日韩第一区| 国产精品久久久久9999| 亚洲私拍自拍| 一本色道久久综合狠狠躁篇的优点 | 欧美亚洲一区二区在线观看| 亚洲啪啪91| 欧美激情小视频| 亚洲精品韩国| 91久久线看在观草草青青| 欧美成在线视频| 日韩亚洲视频在线| 亚洲精品免费一区二区三区| 欧美精品一区二区在线播放| 一本色道久久综合亚洲精品按摩| 亚洲国产精品久久久久| 欧美另类99xxxxx| 中文日韩在线视频| 亚洲免费综合| 在线观看国产欧美| 欧美激情欧美狂野欧美精品| 模特精品在线| 亚洲一区二区精品视频| 亚洲午夜在线| 黄色精品网站| 亚洲国产美女久久久久| 欧美日韩在线精品| 欧美一区日韩一区| 久久亚洲精品中文字幕冲田杏梨| 亚洲国产成人av好男人在线观看| 欧美黄色成人网| 欧美日韩在线播放三区| 久久国内精品自在自线400部| 亚洲中午字幕| 亚洲国产精品福利| 欧美性淫爽ww久久久久无| 亚洲欧美日韩久久精品| 欧美中文字幕在线播放| 亚洲裸体在线观看| 亚洲自拍另类| 亚洲国产日韩欧美在线动漫| 日韩亚洲欧美综合| 国产一区在线播放| 亚洲黄色高清| 国产亚洲欧美另类一区二区三区| 欧美成人高清| 国产精品夜色7777狼人| 亚洲国产高清一区| 国产精品一区二区在线| 最近中文字幕日韩精品| 国产一区二区日韩精品欧美精品| 亚洲第一精品久久忘忧草社区| 欧美偷拍一区二区| 欧美国产精品日韩| 国产日韩精品一区二区浪潮av| 亚洲国产另类久久精品| 国产综合久久久久久| 一本久道久久综合中文字幕| 亚洲风情在线资源站| 午夜精品久久久久久久久久久| 亚洲国产日韩在线一区模特| 亚洲男人第一网站| 在线亚洲欧美视频| 免费中文字幕日韩欧美| 久久性天堂网| 国产视频观看一区| 亚洲深夜福利视频| 一本久道综合久久精品| 麻豆精品视频在线观看| 久久综合电影一区| 国产亚洲欧美一区| 亚洲女同精品视频| 午夜性色一区二区三区免费视频| 欧美高清hd18日本| 亚洲国产合集| 亚洲精品国产精品国自产在线| 久久久久久久激情视频| 久久久美女艺术照精彩视频福利播放| 国产精品国内视频| 亚洲一区二区视频在线| 午夜精品国产精品大乳美女| 国产精品v欧美精品v日韩| 日韩一级片网址| 亚洲图片激情小说| 欧美午夜免费电影| 亚洲视频 欧洲视频| 亚洲一区日韩在线| 国产精品久久999| 亚洲专区一二三| 久久精品国产第一区二区三区最新章节 | 亚洲一区欧美一区| 亚洲尤物在线视频观看| 国产精品福利久久久| 一二三区精品福利视频| 亚洲一区在线观看视频| 国产精品毛片大码女人| av不卡在线观看| 午夜精品三级视频福利| 欧美在线视频网站| 国精品一区二区| 久久久久久欧美| 亚洲电影av| 亚洲小视频在线观看| 国产欧美日韩精品a在线观看| 欧美亚洲色图校园春色| 免费视频一区| 亚洲视频 欧洲视频| 国产精品乱码久久久久久| 欧美在线观看网址综合| 欧美成人中文字幕| 99视频一区二区三区| 国产精品mv在线观看| 午夜精品久久久久久久蜜桃app| 久久久久久午夜| 亚洲另类自拍| 国产精品女主播| 久久久久国产精品厨房| 亚洲精品日产精品乱码不卡| 午夜精品免费在线| 伊人久久久大香线蕉综合直播| 欧美电影专区| 午夜精品福利视频| 最新中文字幕亚洲| 久久aⅴ国产欧美74aaa| 亚洲精品乱码久久久久久蜜桃91| 国产精品久久激情| 久久阴道视频| 亚洲永久免费| 91久久久久久国产精品| 久久精品视频99| 一区二区三区回区在观看免费视频| 国产免费成人在线视频| 欧美高清视频www夜色资源网| 亚洲一区精品在线| 亚洲精品一级| 欧美电影美腿模特1979在线看| 亚洲欧美卡通另类91av | 欧美另类视频在线| 亚洲免费人成在线视频观看| 亚洲电影av在线| 久久久久久自在自线| 亚洲午夜视频在线| 亚洲韩国精品一区| 国产午夜精品美女毛片视频| 欧美小视频在线| 欧美日本视频在线| 欧美成年人网| 久热精品视频在线观看一区|