changes in free memory checks from Maxis (bug #9)

git-svn-id: svn://kolibrios.org@1461 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2010-05-07 17:47:52 +00:00
parent 83d4e309e4
commit 2bc8f0feb7

View File

@ -14,6 +14,11 @@ proc alloc_page
pushfd pushfd
cli cli
push ebx push ebx
;//-
cmp [pg_data.pages_free], 1
jle .out_of_memory
;//-
mov ebx, [page_start] mov ebx, [page_start]
mov ecx, [page_end] mov ecx, [page_end]
.l1: .l1:
@ -27,15 +32,27 @@ proc alloc_page
xor eax,eax xor eax,eax
ret ret
.found: .found:
;//-
dec [pg_data.pages_free]
jz .out_of_memory
;//-
btr [ebx], eax btr [ebx], eax
mov [page_start],ebx mov [page_start],ebx
sub ebx, sys_pgmap sub ebx, sys_pgmap
lea eax, [eax+ebx*8] lea eax, [eax+ebx*8]
shl eax, 12 shl eax, 12
dec [pg_data.pages_free] ;//- dec [pg_data.pages_free]
pop ebx pop ebx
popfd popfd
ret ret
;//-
.out_of_memory:
mov [pg_data.pages_free], 1
xor eax, eax
pop ebx
popfd
ret
;//-
endp endp
align 4 align 4
@ -48,9 +65,14 @@ proc alloc_pages stdcall, count:dword
add eax, 7 add eax, 7
shr eax, 3 shr eax, 3
mov [count], eax mov [count], eax
cmp eax, [pg_data.pages_free] ;//-
ja .fail mov ebx, [pg_data.pages_free]
sub ebx, 9
js .out_of_memory
shr ebx, 3
cmp eax, ebx
jg .out_of_memory
;//-
mov ecx, [page_start] mov ecx, [page_start]
mov ebx, [page_end] mov ebx, [page_end]
.find: .find:
@ -64,6 +86,7 @@ proc alloc_pages stdcall, count:dword
inc ecx inc ecx
cmp ecx,ebx cmp ecx,ebx
jb .match jb .match
.out_of_memory:
.fail: .fail:
xor eax, eax xor eax, eax
pop edi pop edi
@ -479,6 +502,15 @@ proc new_mem_resize stdcall, new_size:dword
cmp edi, esi cmp edi, esi
jb @B jb @B
.grow: .grow:
;//-
pop edi
push edi
mov esi, [pg_data.pages_free]
sub esi, 1
shr edi, 12
cmp esi, edi
jle .out_of_memory
;//-
pop edi pop edi
pop esi pop esi
@@: @@:
@ -500,7 +532,10 @@ proc new_mem_resize stdcall, new_size:dword
jb @B jb @B
jmp .update_size jmp .update_size
;//-
.exit_pop: .exit_pop:
.out_of_memory:
;//-
pop edi pop edi
pop esi pop esi
.exit: .exit: