Introduced vm_page_try_reserve_pages(), which fails when not enough

pages are free ATM.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27116 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-08-21 22:43:52 +00:00
parent cc57c65424
commit 2e8e6c9c6e
2 changed files with 20 additions and 0 deletions

View File

@ -46,6 +46,7 @@ void vm_page_schedule_write_page_range(struct VMCache *cache,
void vm_page_unreserve_pages(uint32 count);
void vm_page_reserve_pages(uint32 count);
bool vm_page_try_reserve_pages(uint32 count);
struct vm_page *vm_page_allocate_page(int pageState, bool reserved);
status_t vm_page_allocate_pages(int pageState, struct vm_page **pages,

View File

@ -1756,6 +1756,25 @@ vm_page_reserve_pages(uint32 count)
}
bool
vm_page_try_reserve_pages(uint32 count)
{
if (count == 0)
return true;
InterruptsSpinLocker locker(sPageLock);
T(ReservePages(count));
size_t freePages = free_page_queue_count();
if (sReservedPages + count > freePages)
return false;
sReservedPages += count;
return true;
}
vm_page *
vm_page_allocate_page(int pageState, bool reserved)
{