Small optimizations in shed.

Fixed memory leak when not enough memory for starting application.
Deleted old code writing to TSS of system call handler.

git-svn-id: svn://kolibrios.org@9 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Andrey Halyavin (halyavin) 2005-10-17 15:38:11 +00:00
parent bd15d25cab
commit c57ff1bc79
3 changed files with 47 additions and 29 deletions

View File

@ -151,7 +151,7 @@ new_start_application_floppy:
mov edx,eax mov edx,eax
call mem_alloc_specified_region ;allocate memory for application call mem_alloc_specified_region ;allocate memory for application
test eax,eax test eax,eax
jz .cleanfailed_mem jz .cleanfailed_mem1
mov eax,[edx+(std_application_base_address shr 20)] mov eax,[edx+(std_application_base_address shr 20)]
and eax,not (4096-1) ;eax - physical address of first (for application memory) page table and eax,not (4096-1) ;eax - physical address of first (for application memory) page table
@ -195,10 +195,21 @@ new_start_application_floppy:
mov [esp+28],eax mov [esp+28],eax
popad popad
ret ret
.cleanfailed_mem1:
;there is mem for directory entry, but there is no mem for pages
;so free directory entry
mov eax,[new_process_place]
shl eax,8
mov eax,[0x80000+eax+0xB8]
call MEM_Free_Page
.cleanfailed_mem: .cleanfailed_mem:
;there is no mem for directory entry, display message.
mov esi,start_not_enough_memory mov esi,start_not_enough_memory
call sys_msg_board_str call sys_msg_board_str
.cleanfailed: ;clean process name .cleanfailed: ;clean process name
;can't read file, clean process name.
;this avoid problems with panel application.
mov edi,[new_process_place] mov edi,[new_process_place]
shl edi,8 shl edi,8
add edi,0x80000 add edi,0x80000
@ -207,6 +218,7 @@ new_start_application_floppy:
cld cld
rep stosb rep stosb
.failed: .failed:
;no more slots
add esp,8+4 add esp,8+4
mov [application_table_status],0 mov [application_table_status],0
popad popad
@ -296,7 +308,7 @@ new_start_application_fl:
mov edx,eax mov edx,eax
call mem_alloc_specified_region ;allocate memory for application call mem_alloc_specified_region ;allocate memory for application
test eax,eax test eax,eax
jz .cleanfailed_mem jz .cleanfailed_mem1
mov eax,[edx+(std_application_base_address shr 20)] mov eax,[edx+(std_application_base_address shr 20)]
and eax,not (4096-1) ;eax - physical address of first (for application memory) page table and eax,not (4096-1) ;eax - physical address of first (for application memory) page table
@ -340,10 +352,20 @@ new_start_application_fl:
popad popad
ret ret
.cleanfailed_mem1:
;there is mem for directory entry, but there is no mem for pages
;so free directory entry
mov eax,[new_process_place]
shl eax,8
mov eax,[0x80000+eax+0xB8]
call MEM_Free_Page
.cleanfailed_mem: .cleanfailed_mem:
;there is no mem for directory entry, display message.
mov esi,start_not_enough_memory mov esi,start_not_enough_memory
call sys_msg_board_str call sys_msg_board_str
.cleanfailed: ;clean process name .cleanfailed: ;clean process name
;can't read file, clean process name.
;this avoid problems with panel application.
mov edi,[new_process_place] mov edi,[new_process_place]
shl edi,8 shl edi,8
add edi,0x80000 add edi,0x80000
@ -352,6 +374,7 @@ new_start_application_fl:
cld cld
rep stosb rep stosb
.failed: .failed:
;no more slots
add esp,8 add esp,8
mov [application_table_status],0 mov [application_table_status],0
popad popad
@ -450,10 +473,6 @@ new_start_application_fl:
mov eax,[0x800B8+ecx] mov eax,[0x800B8+ecx]
add eax,8+16 ;add flags add eax,8+16 ;add flags
mov [l.cr3],eax mov [l.cr3],eax
;write cr3 in TSS of System Call Handler
mov ecx,[new_process_place]
shl ecx,7
mov [0x298000+ecx+l.cr3-tss_sceleton],eax ;write directy to TSS
mov eax,[app_start] mov eax,[app_start]
mov [l.eip],eax ;set eip in TSS mov [l.eip],eax ;set eip in TSS
@ -1231,7 +1250,7 @@ new_start_application_hd:
mov edx,eax ;edx - linear address of page directory mov edx,eax ;edx - linear address of page directory
call mem_alloc_specified_region ;allocate memory for application call mem_alloc_specified_region ;allocate memory for application
test eax,eax test eax,eax
jz .cleanfailed_mem jz .cleanfailed_mem1
add edx,(std_application_base_address shr 20) add edx,(std_application_base_address shr 20)
mov eax,[edx] mov eax,[edx]
@ -1306,10 +1325,20 @@ new_start_application_hd:
popad popad
ret ret
.cleanfailed_mem1:
;there is mem for directory entry, but there is no mem for pages
;so free directory entry
mov eax,[new_process_place]
shl eax,8
mov eax,[0x80000+eax+0xB8]
call MEM_Free_Page
.cleanfailed_mem: .cleanfailed_mem:
;there is no mem for directory entry, display message.
mov esi,start_not_enough_memory mov esi,start_not_enough_memory
call sys_msg_board_str call sys_msg_board_str
.cleanfailed: ;clean process name .cleanfailed: ;clean process name
;can't read file, clean process name.
;this avoid problems with panel application.
mov edi,[new_process_place] mov edi,[new_process_place]
shl edi,8 shl edi,8
add edi,0x80000 add edi,0x80000
@ -1318,6 +1347,7 @@ new_start_application_hd:
cld cld
rep stosb rep stosb
.failed: .failed:
;no more slots
add esp,16 add esp,16
popad popad
mov eax,-1 mov eax,-1

View File

@ -40,6 +40,7 @@ irq0:
mov ebx,[0x3000] mov ebx,[0x3000]
xor esi,esi ;esi - should we change task?
cmp [0xffff], byte 1 cmp [0xffff], byte 1
je .do_not_change_task je .do_not_change_task
@ -67,7 +68,7 @@ irq0:
jmp @f jmp @f
.do_not_change_task: .do_not_change_task:
mov [noct], 1 inc esi ;set don't change task flag
@@: @@:
call _rdtsc call _rdtsc
@ -89,14 +90,14 @@ irq0:
mov dx,0x20 mov dx,0x20
out dx,al out dx,al
cmp [noct], 1 test esi,esi ; skip jmp to TSS if we aren't going to switch tasks
je @f jnz @f
.switch:
jmp pword [0xB000]
inc [context_counter] ;noname & halyavin
@@:
mov [noct], 0
.switch:
inc [context_counter] ;noname & halyavin
jmp pword [0xB000]
@@:
pop es ds pop es ds
popad popad
iret iret
@ -105,7 +106,6 @@ irq0:
uglobal uglobal
context_counter dd 0 ;noname & halyavin context_counter dd 0 ;noname & halyavin
noct db 0
endg endg

View File

@ -232,9 +232,6 @@ iglobal
endg endg
writehex: writehex:
pusha pusha
@ -363,10 +360,6 @@ irqD:
uglobal
irqh dd 0x0
endg
irqhandler: irqhandler:
push edi push edi
@ -599,11 +592,6 @@ terminate: ; terminate application
mov esi,process_terminating mov esi,process_terminating
call sys_msg_board_str call sys_msg_board_str
pop esi pop esi
;start memory manager code
; mov eax,esi
; call MEM_Heap_Clean
;end memory manager code
cli cli
cmp [application_table_status],0 cmp [application_table_status],0