Rev 1310 | Rev 1314 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1310 | Rev 1311 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 1310 $ |
8 | $Revision: 1311 $ |
Line 9... | Line 9... | ||
9 | 9 | ||
Line 484... | Line 484... | ||
484 | ret |
484 | ret |
485 | .fail: |
485 | .fail: |
486 | dec [pg_data.pg_mutex] |
486 | dec [pg_data.pg_mutex] |
487 | cmp [dir_addr], 0 |
487 | cmp [dir_addr], 0 |
488 | je @f |
488 | je @f |
489 | stdcall destroy_app_space, [dir_addr] |
489 | stdcall destroy_app_space, [dir_addr], 0 |
490 | @@: |
490 | @@: |
491 | xor eax, eax |
491 | xor eax, eax |
492 | ret |
492 | ret |
493 | endp |
493 | endp |
Line 521... | Line 521... | ||
521 | pop esi |
521 | pop esi |
522 | ret |
522 | ret |
523 | endp |
523 | endp |
Line 524... | Line 524... | ||
524 | 524 | ||
525 | align 4 |
525 | align 4 |
526 | proc destroy_app_space stdcall, pg_dir:dword |
- | |
527 | - | ||
528 | mov ebx, pg_data.pg_mutex |
- | |
Line 529... | Line 526... | ||
529 | call wait_mutex ;ebx |
526 | proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword |
- | 527 | ||
530 | 528 | xor edx,edx |
|
531 | xor edx,edx |
529 | push edx |
532 | mov eax,0x2 |
530 | mov eax,0x2 |
533 | mov ebx, [pg_dir] |
531 | mov ebx, [pg_dir] |
534 | .loop: |
532 | .loop: |
535 | ;eax = current slot of process |
533 | ;eax = current slot of process |
536 | mov ecx,eax |
534 | mov ecx,eax |
537 | shl ecx,5 |
535 | shl ecx,5 |
538 | cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? |
536 | cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? |
- | 537 | jz @f ;skip empty slots |
|
539 | jz @f ;skip empty slots |
538 | shl ecx,3 |
540 | shl ecx,3 |
539 | add ecx,SLOT_BASE |
- | 540 | cmp [ecx+APPDATA.dir_table],ebx ;compare page directory addresses |
|
541 | cmp [SLOT_BASE+ecx+0xB8],ebx ;compare page directory addresses |
541 | jnz @f |
542 | jnz @f |
542 | mov [ebp-4],ecx |
543 | inc edx ;thread found |
543 | inc edx ;thread found |
544 | @@: |
544 | @@: |
545 | inc eax |
545 | inc eax |
Line 546... | Line 546... | ||
546 | cmp eax,[TASK_COUNT] ;exit loop if we look through all processes |
546 | cmp eax,[TASK_COUNT] ;exit loop if we look through all processes |
547 | jle .loop |
547 | jle .loop |
- | 548 | ||
548 | 549 | ;edx = number of threads |
|
549 | ;edx = number of threads |
550 | ;our process is zombi so it isn't counted |
550 | ;our process is zombi so it isn't counted |
551 | pop ecx |
- | 552 | cmp edx,1 |
|
- | 553 | jg .ret |
|
- | 554 | ;if there isn't threads then clear memory. |
|
- | 555 | mov esi, [dlls_list] |
|
- | 556 | call destroy_all_hdlls |
|
Line 551... | Line 557... | ||
551 | cmp edx,1 |
557 | |
552 | jg .exit |
558 | mov ebx, pg_data.pg_mutex |
553 | ;if there isn't threads then clear memory. |
559 | call wait_mutex ;ebx |
554 | 560 | ||
555 | mov eax, [pg_dir] |
561 | mov eax, [pg_dir] |
556 | and eax, not 0xFFF |
562 | and eax, not 0xFFF |
557 | stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
563 | stdcall map_page,[tmp_task_pdir],eax,PG_SW |
558 | mov esi, [tmp_task_pdir] |
564 | mov esi, [tmp_task_pdir] |
559 | mov edi, (OS_BASE shr 20)/4 |
565 | mov edi, (OS_BASE shr 20)/4 |
560 | .destroy: |
566 | .destroy: |
561 | mov eax, [esi] |
567 | mov eax, [esi] |
562 | test eax, 1 |
568 | test eax, 1 |
563 | jz .next |
569 | jz .next |
564 | and eax, not 0xFFF |
570 | and eax, not 0xFFF |
565 | stdcall map_page,[tmp_task_ptab],eax,dword PG_SW |
571 | stdcall map_page,[tmp_task_ptab],eax,PG_SW |
566 | stdcall destroy_page_table, [tmp_task_ptab] |
572 | stdcall destroy_page_table, [tmp_task_ptab] |
Line 572... | Line 578... | ||
572 | jnz .destroy |
578 | jnz .destroy |
Line 573... | Line 579... | ||
573 | 579 | ||
574 | mov eax, [pg_dir] |
580 | mov eax, [pg_dir] |
575 | call free_page |
581 | call free_page |
576 | .exit: |
582 | .exit: |
577 | stdcall map_page,[tmp_task_ptab],dword 0,dword PG_UNMAP |
583 | stdcall map_page,[tmp_task_ptab],0,PG_UNMAP |
578 | stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
584 | stdcall map_page,[tmp_task_pdir],0,PG_UNMAP |
- | 585 | dec [pg_data.pg_mutex] |
|
579 | dec [pg_data.pg_mutex] |
586 | .ret: |
580 | ret |
587 | ret |
Line 581... | Line 588... | ||
581 | endp |
588 | endp |
582 | 589 | ||
Line 906... | Line 913... | ||
906 | mov [edx+APPDATA.mem_size], eax |
913 | mov [edx+APPDATA.mem_size], eax |
Line 907... | Line 914... | ||
907 | 914 | ||
908 | mov ecx,[ebx+APPDATA.dir_table] |
915 | mov ecx,[ebx+APPDATA.dir_table] |
Line -... | Line 916... | ||
- | 916 | mov [edx+APPDATA.dir_table],ecx ;copy page directory |
|
- | 917 | ||
- | 918 | mov eax,[ebx+APPDATA.dlls_list_ptr] |
|
909 | mov [edx+APPDATA.dir_table],ecx ;copy page directory |
919 | mov [edx+APPDATA.dlls_list_ptr],eax |
910 | 920 | ||
911 | mov eax, [ebx+APPDATA.tls_base] |
921 | mov eax, [ebx+APPDATA.tls_base] |
Line 912... | Line 922... | ||
912 | test eax, eax |
922 | test eax, eax |