Replaced the sAvailableMemoryLock benaphore with a mutex.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25379 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-05-08 15:57:59 +00:00
parent adf376c941
commit 06b580d76f
+6 -7
View File
@@ -197,7 +197,7 @@ static mutex sMappingLock;
static mutex sAreaCacheLock; static mutex sAreaCacheLock;
static off_t sAvailableMemory; static off_t sAvailableMemory;
static benaphore sAvailableMemoryLock; static mutex sAvailableMemoryLock;
// function declarations // function declarations
static void delete_area(vm_address_space *addressSpace, vm_area *area); static void delete_area(vm_address_space *addressSpace, vm_area *area);
@@ -3583,7 +3583,6 @@ vm_init(kernel_args *args)
// initialize some globals // initialize some globals
sNextAreaID = 1; sNextAreaID = 1;
sAreaHashLock = -1; sAreaHashLock = -1;
sAvailableMemoryLock.sem = -1;
vm_page_init_num_pages(args); vm_page_init_num_pages(args);
sAvailableMemory = vm_page_num_pages() * B_PAGE_SIZE; sAvailableMemory = vm_page_num_pages() * B_PAGE_SIZE;
@@ -3690,7 +3689,7 @@ vm_init_post_sem(kernel_args *args)
// since we're still single threaded and only the kernel address space exists, // since we're still single threaded and only the kernel address space exists,
// it isn't that hard to find all of the ones we need to create // it isn't that hard to find all of the ones we need to create
benaphore_init(&sAvailableMemoryLock, "available memory lock"); mutex_init(&sAvailableMemoryLock, "available memory lock");
arch_vm_translation_map_init_post_sem(args); arch_vm_translation_map_init_post_sem(args);
vm_address_space_init_post_sem(); vm_address_space_init_post_sem();
@@ -4484,11 +4483,11 @@ vm_put_physical_page(addr_t vaddr)
void void
vm_unreserve_memory(size_t amount) vm_unreserve_memory(size_t amount)
{ {
benaphore_lock(&sAvailableMemoryLock); mutex_lock(&sAvailableMemoryLock);
sAvailableMemory += amount; sAvailableMemory += amount;
benaphore_unlock(&sAvailableMemoryLock); mutex_unlock(&sAvailableMemoryLock);
} }
@@ -4496,7 +4495,7 @@ status_t
vm_try_reserve_memory(size_t amount) vm_try_reserve_memory(size_t amount)
{ {
status_t status; status_t status;
benaphore_lock(&sAvailableMemoryLock); mutex_lock(&sAvailableMemoryLock);
//dprintf("try to reserve %lu bytes, %Lu left\n", amount, sAvailableMemory); //dprintf("try to reserve %lu bytes, %Lu left\n", amount, sAvailableMemory);
@@ -4506,7 +4505,7 @@ vm_try_reserve_memory(size_t amount)
} else } else
status = B_NO_MEMORY; status = B_NO_MEMORY;
benaphore_unlock(&sAvailableMemoryLock); mutex_unlock(&sAvailableMemoryLock);
return status; return status;
} }