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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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 楊粼波 閱讀(926) 評論(2)  編輯 收藏 引用

評論

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

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

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

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


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲综合色噜噜狠狠| 快播亚洲色图| 欧美不卡高清| 久久久不卡网国产精品一区| 欧美呦呦网站| 欧美大片一区二区| 91久久精品国产91久久性色tv| 久久蜜桃av一区精品变态类天堂| 欧美一区在线直播| 久久亚洲风情| 亚洲国产精品尤物yw在线观看| 亚洲精品美女久久7777777| 亚洲一区二区伦理| 久久久久欧美| 欧美日韩在线观看一区二区三区| 国产女人水真多18毛片18精品视频| 国内精品国产成人| 夜夜狂射影院欧美极品| 欧美一区国产一区| 欧美成人中文字幕| 一二美女精品欧洲| 久久久国产亚洲精品| 欧美激情综合亚洲一二区| 国产精品毛片在线看| 1024国产精品| 香蕉av福利精品导航| 亚洲高清不卡| 久久九九国产精品怡红院| 欧美日韩高清在线一区| 韩国精品久久久999| 亚洲免费在线播放| 欧美电影在线观看| 亚洲欧美日韩国产综合精品二区| 老牛嫩草一区二区三区日本| 欧美午夜大胆人体| 午夜精品成人在线视频| 欧美高清影院| 樱桃视频在线观看一区| 午夜视频一区二区| 一本色道久久99精品综合 | 国产精品剧情在线亚洲| 亚洲成色精品| 久久亚洲国产成人| 性欧美xxxx大乳国产app| 欧美午夜视频| 欧美大色视频| 夜夜嗨av一区二区三区免费区| 久久亚洲国产精品日日av夜夜| 亚洲激情综合| 久久精品国产视频| 国产中文一区二区| 久久激情五月激情| 午夜在线成人av| 国产嫩草影院久久久久 | 亚洲激情视频在线| 久久人人爽国产| 久久99伊人| 韩日精品中文字幕| 久久亚洲私人国产精品va| 午夜精品久久久久久久99黑人| 欧美色图首页| 亚洲午夜在线观看| 一区二区三区成人| 欧美午夜欧美| 欧美一级电影久久| 亚欧美中日韩视频| 樱花yy私人影院亚洲| 免费在线欧美视频| 久久久之久亚州精品露出| 尤物在线精品| 亚洲国产日韩在线| 欧美日韩一区二区欧美激情 | 欧美日韩中文另类| 欧美亚洲自偷自偷| 久久综合精品国产一区二区三区| 亚洲国产成人在线播放| 亚洲国产一二三| 国产精品理论片| 久久精品一区二区| 久久婷婷激情| 一本色道久久综合亚洲精品小说 | 国产亚洲制服色| 蜜臀av一级做a爰片久久| 你懂的视频一区二区| 欧美/亚洲一区| 亚洲午夜91| 欧美中文在线观看| 亚洲美洲欧洲综合国产一区| 99成人在线| 永久久久久久| 在线亚洲精品| 亚洲高清av在线| 亚洲午夜高清视频| 亚洲国产一区二区三区高清| 正在播放欧美视频| 亚洲国产视频一区| 亚洲淫片在线视频| 亚洲精品美女| 午夜欧美精品| 亚洲视频高清| 米奇777超碰欧美日韩亚洲| 亚洲男人影院| 欧美国产高潮xxxx1819| 欧美一级大片在线免费观看| 欧美经典一区二区| 欧美va天堂| 国产亚洲综合精品| 亚洲视频第一页| 一本大道久久a久久精品综合| 欧美在线观看视频一区二区| 在线亚洲伦理| 欧美精品在线看| 免费短视频成人日韩| 国产精品一区二区你懂得| 亚洲精品乱码久久久久久按摩观| 狠狠久久亚洲欧美| 亚洲欧美另类久久久精品2019| 亚洲七七久久综合桃花剧情介绍| 欧美一区二区三区免费观看| 亚洲一级在线观看| 欧美日韩在线视频一区| 亚洲人屁股眼子交8| 亚洲精品乱码久久久久久黑人| 久久精品一区二区三区四区| 欧美一级专区免费大片| 国产精品毛片| 亚洲在线视频观看| 午夜精品久久久久久久蜜桃app| 欧美激情综合亚洲一二区| 亚洲第一狼人社区| 亚洲精品一线二线三线无人区| 久久综合给合| 欧美激情乱人伦| 亚洲精品一区二区三区不| 欧美成人一二三| 亚洲日本中文| 正在播放亚洲一区| 欧美亚洲不卡| 亚洲女人av| 快射av在线播放一区| 亚洲电影免费观看高清完整版| 快播亚洲色图| 亚洲精品久久嫩草网站秘色| 99视频+国产日韩欧美| 欧美日韩成人在线播放| 99国内精品| 亚洲欧美日韩一区在线观看| 国产精品视频导航| 久久国产精品第一页 | 亚洲视频中文| 国产午夜精品理论片a级探花| 午夜伦欧美伦电影理论片| 久久人人爽人人爽| 亚洲国产一区在线| 欧美色欧美亚洲高清在线视频| 在线天堂一区av电影| 久久国产精品久久w女人spa| 精品成人在线视频| 欧美激情第三页| 亚洲一区二区三区在线观看视频 | 99这里只有久久精品视频| 亚洲免费在线电影| 国产亚洲一本大道中文在线| 久热国产精品| 亚洲一区二区欧美日韩| 久久米奇亚洲| 亚洲校园激情| 黄色精品网站| 国产精品第2页| 狂野欧美激情性xxxx| 亚洲网站视频福利| 欧美本精品男人aⅴ天堂| 中文久久精品| 在线观看av不卡| 国产精品高潮呻吟久久av无限 | 裸体女人亚洲精品一区| 99国产精品视频免费观看| 久久精品99国产精品| 一本一本久久| 伊人春色精品| 国产精品久久久久一区| 美日韩在线观看| 欧美一级免费视频| 99精品欧美一区二区三区综合在线| 久久精品国亚洲| 亚洲影音先锋| 99热免费精品| 亚洲国产精品福利| 国产欧美成人| 国产精品v亚洲精品v日韩精品| 免费久久99精品国产自| 欧美中文字幕在线| 亚洲影院在线观看| 亚洲最快最全在线视频| 欧美国产综合| 一区二区三区成人精品| 亚洲欧洲av一区二区三区久久| 欧美日韩国产丝袜另类| 99精品国产福利在线观看免费 | 欧美成年人网|