Aktív témák

  • P.H.

    senior tag

    Pufferenként 1-1 előre elindított végtelenített szál + pufferenként 2 event:
    - Erase: automatikusan resetelt, 0 kezdőértékkel
    - Ready: kézileg resetelt, 0 kezdőértékkel

    procedure _ZTHREAD;
    { [ESP+04h]: TBUFFER address
    asm mov edx,[esp+04h]
    pushad
    mov edi,[edx+TBUFFER.BIT]
    mov esi,edx
    mov ebp,[edx+TBUFFER.ERASE]
    mov ebx,offset(BUFFERS)
    xor edi,-1
    @loop:
    push INFINITE; push ebp; call WINDOWS.WAITFORSINGLEOBJECT
    mov eax,[esi+TBUFFER.ADDR]; mov edx,[esi+TBUFFER.SIZE]; call _ZEROMEM
    push dword ptr [esi+TBUFFER.READY]; call WINDOWS.SETEVENT
    lock and [ebx+_LOCKBITS],edi
    lock and [ebx+_PENDINGS],edi
    jmp @loop
    popad
    ret 04h end;
    procedure _FREEBUFFER(Value:pHGLOBAL);
    asm mov edx,eax
    xor ecx,ecx
    mov eax,[eax]
    mov [edx],ecx
    mov cl,cBUFFER
    test eax,eax
    mov edx,offset(BUFFERS)
    jz @return
    @search:
    sub cl,01h
    lea edx,[edx+TBUFFERSIZE]
    js @error
    cmp eax,[edx+TBUFFER.ADDR]
    jnz @search
    @freebuffer:
    cmp byte ptr [_INSSET+__CPUs],01h
    mov ecx,[edx+TBUFFER.BIT]
    jbe @oneCPU
    lock or dword ptr [BUFFERS+_PENDINGS],ecx
    push dword ptr [edx+TBUFFER.ERASE]; call WINDOWS.SETEVENT
    ret
    @oneCPU:
    xor ecx,-1
    mov eax,[edx+TBUFFER.ADDR]; mov edx,[edx+TBUFFER.SIZE]
    and dword ptr [BUFFERS+_LOCKBITS],ecx
    jmp _ZEROMEM
    @error:
    mov eax,[_NOFREE]
    jmp ERRORFORM
    @return: end;
    procedure _RESTARTBUFFERS;
    asm pushad
    mov edx,offset(BUFFERS); or ecx,-1
    xor edi,edi
    mov eax,[edx+_PENDINGS]; call _WAITFORBUFFER
    mov esi,edx
    mov ebp,[edx+_LOCKBITS]
    mov bl,cBUFFER
    mov [edx+_LOCKBITS],edi
    mov [edx+_PENDINGS],edi
    add edi,01h
    @search:
    sub bl,01h
    lea esi,[esi+TBUFFERSIZE]
    js @return
    test ebp,edi
    lea edi,[edi+edi]
    jz @search
    mov eax,[esi+TBUFFER.ADDR]; mov edx,[esi+TBUFFER.SIZE]; call _ZEROMEM
    jmp @search
    @return:
    popad end;
    function _WAITFORBUFFER: DWORD;
    asm test eax,eax
    pushad
    mov edi,ecx
    mov ebx,esp
    jz @return
    xor ebp,ebp
    @threadarray:
    shr eax,01h
    lea edx,[edx+TBUFFERSIZE]
    jnc @threadarray
    lea ebp,[ebp+01h]
    push dword ptr [edx+TBUFFER.READY]
    jnz @threadarray
    mov edx,esp
    push INFINITE; push edi; push edx; push ebp; call WINDOWS.WAITFORMULTIPLEOBJECTS
    mov esp,ebx
    @return:
    popad
    test eax,eax end;
    function _GETBUFFER(Dest:pHGLOBAL): HGLOBAL;
    asm pushad
    mov esi,offset(BUFFERS)
    mov edi,eax
    @testbuffers:
    mov ebp,[esi+_LOCKBITS]
    mov ebx,00000001h
    mov edx,esi
    mov cl,cBUFFER
    mov eax,[esi+_PENDINGS]
    @search:
    test ebp,ebx
    lea esi,[esi+TBUFFERSIZE]
    jz @lock
    sub cl,01h
    lea ebx,[ebx+ebx]
    jg @search
    cmp ebp,[edx+_LOCKBITS]
    mov esi,edx
    jnz @testbuffers
    xor ecx,ecx; call _WAITFORBUFFER
    jnz @testbuffers
    @error:
    mov eax,[_NOGET]; call ERRORFORM
    xor ebx,ebx
    mov edx,esi
    @lock:
    mov eax,[esi+TBUFFER.ADDR]
    lock or [edx+_LOCKBITS],ebx
    mov [edi],eax
    push dword ptr [esi+TBUFFER.READY]; call WINDOWS.RESETEVENT
    popad
    mov eax,[eax] end;

    [ Szerkesztve ]

    Arguing on the Internet is like running in the Special Olympics. Even if you win, you are still ... ˙˙˙ Real Eyes Realize Real Lies ˙˙˙

Aktív témák