Subversion Repositories Kolibri OS

Rev

Rev 4457 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4457 Rev 4459
Line 585... Line 585...
585
        mov     ecx, 1024
585
        mov     ecx, 1024
586
.free:
586
.free:
587
        mov     eax, [esi]
587
        mov     eax, [esi]
588
        test    eax, 1
588
        test    eax, 1
589
        jz      .next
589
        jz      .next
-
 
590
        test    eax, 2
-
 
591
        jz      .next
590
        test    eax, 1 shl 9
592
        test    eax, 1 shl 9
591
        jnz     .next                     ;skip shared pages
593
        jnz     .next                     ;skip shared pages
592
        call    free_page
594
        call    free_page
593
.next:
595
.next:
594
        add     esi, 4
596
        add     esi, 4
Line 597... Line 599...
597
        pop     esi
599
        pop     esi
598
        ret
600
        ret
599
endp
601
endp
Line 600... Line 602...
600
 
602
 
601
align 4
603
align 4
Line 602... Line -...
602
proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword
-
 
603
 
-
 
604
        xor     edx, edx
-
 
605
        push    edx
604
destroy_process: ;fastcall ecx= ptr to process
606
        mov     eax, 0x1
-
 
607
        mov     ebx, [pg_dir]
-
 
608
.loop:
605
 
609
;eax = current slot of process
-
 
610
        mov     ecx, eax
-
 
611
        shl     ecx, 5
-
 
612
        cmp     byte [CURRENT_TASK+ecx+0xa], 9;if process running?
-
 
613
        jz      @f           ;skip empty slots
-
 
614
        shl     ecx, 3
-
 
615
        add     ecx, SLOT_BASE
-
 
616
        cmp     [ecx+APPDATA.process], ebx;compare page directory addresses
-
 
617
        jnz     @f
-
 
618
        mov     [ebp-4], ecx
-
 
619
        inc     edx             ;thread found
-
 
620
@@:
-
 
621
        inc     eax
606
        lea     eax, [ecx+PROC.thr_list]
Line 622... Line -...
622
        cmp     eax, [TASK_COUNT]   ;exit loop if we look through all processes
-
 
623
        jle     .loop
-
 
624
 
607
        cmp     eax, [eax+LHEAD.next]
625
;edx = number of threads
608
        jne     .exit
626
;our process is zombi so it isn't counted
609
 
627
        pop     ecx
-
 
628
        cmp     edx, 1
-
 
629
        jg      .ret
-
 
Line 630... Line 610...
630
;if there isn't threads then clear memory.
610
align 4
631
        mov     esi, [dlls_list]
611
.internal:
Line 632... Line 612...
632
        call    destroy_all_hdlls;ecx=APPDATA
612
        push    ecx
633
 
613
 
-
 
614
        mov     esi, [ecx+PROC.dlls_list_ptr]
634
        mov     ecx, pg_data.mutex
615
        call    destroy_all_hdlls
635
        call    mutex_lock
616
 
636
 
617
;        mov     ecx, pg_data.mutex
637
        mov     eax, [pg_dir]
618
;        call    mutex_lock
638
        and     eax, not 0xFFF
619
 
639
;        stdcall map_page, [tmp_task_pdir], eax, PG_SW
620
        mov     esi, [esp]
640
;        mov     esi, [tmp_task_pdir]
621
        add     esi, PROC.pdt_0
641
        mov     edi, (OS_BASE shr 20)/4
622
        mov     edi, (0x80000000 shr 20)/4
Line 651... Line 632...
651
.next:
632
.next:
652
        add     esi, 4
633
        add     esi, 4
653
        dec     edi
634
        dec     edi
654
        jnz     .destroy
635
        jnz     .destroy
Line 655... Line -...
655
 
-
 
656
        mov     eax, [pg_dir]
636
 
657
        call    free_page
-
 
658
.exit:
637
        call kernel_free  ;ecx still in stack
659
        stdcall map_page, [tmp_task_ptab], 0, PG_UNMAP
-
 
660
;        stdcall map_page, [tmp_task_pdir], 0, PG_UNMAP
638
        stdcall map_page, [tmp_task_ptab], 0, PG_UNMAP
661
        mov     ecx, pg_data.mutex
639
 ;       mov     ecx, pg_data.mutex
-
 
640
 ;       call    mutex_unlock
662
        call    mutex_unlock
641
 
663
.ret:
642
.exit:
664
        ret
-
 
Line 665... Line 643...
665
endp
643
        ret
666
 
644
 
667
align 4
645
align 4
668
get_pid:
646
get_pid:
Line 984... Line 962...
984
        mov     eax, [ebx+APPDATA.process]
962
        mov     eax, [ebx+APPDATA.process]
985
        mov     [edx+APPDATA.process], eax
963
        mov     [edx+APPDATA.process], eax
Line 986... Line 964...
986
 
964
 
987
        lea     ebx, [edx+APPDATA.list]
965
        lea     ebx, [edx+APPDATA.list]
988
        lea     ecx, [eax+PROC.thr_list]
966
        lea     ecx, [eax+PROC.thr_list]
Line 989... Line 967...
989
        list_add_tail edx, ecx               ;add thread to process child's list
967
        list_add_tail ebx, ecx               ;add thread to process child's list
990
 
968
 
991
        mov     eax, [ebx+APPDATA.tls_base]
969
        mov     eax, [ebx+APPDATA.tls_base]