* Reserved areas would also be created in existing reserved areas in case the

space was becoming tight. This actually fixes #4778.
* Fixed overflow problem in find_reserved_area().
* Cleaned up the test app, added license.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33597 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-10-15 11:23:38 +00:00
parent 9b912c694a
commit 4124f4801b
2 changed files with 15 additions and 10 deletions
+5 -5
View File
@@ -1022,8 +1022,8 @@ find_reserved_area(vm_address_space* addressSpace, addr_t start,
next = addressSpace->areas;
while (next != NULL) {
if (next->base <= start
&& next->base + next->size > start + (size - 1)) {
// this area covers the requested range
&& next->base + (next->size - 1) >= start + (size - 1)) {
// This area covers the requested range
if (next->id != RESERVED_AREA_ID) {
// but it's not reserved space, it's a real area
return B_BAD_VALUE;
@@ -1039,7 +1039,7 @@ find_reserved_area(vm_address_space* addressSpace, addr_t start,
if (next == NULL)
return B_ENTRY_NOT_FOUND;
// now we have to transfer the requested part of the reserved
// Now we have to transfer the requested part of the reserved
// range to the new area - and remove, resize or split the old
// reserved area.
@@ -1126,7 +1126,7 @@ find_and_insert_area_slot(vm_address_space* addressSpace, addr_t start,
|| start + (size - 1) > end)
return B_BAD_ADDRESS;
if (addressSpec == B_EXACT_ADDRESS) {
if (addressSpec == B_EXACT_ADDRESS && area->id != RESERVED_AREA_ID) {
// search for a reserved area
status_t status = find_reserved_area(addressSpace, start, size, area);
if (status == B_OK || status == B_BAD_VALUE)
@@ -1206,7 +1206,7 @@ second_chance:
foundSpot = true;
area->base = alignedBase;
break;
} else {
} else if (area->id != RESERVED_AREA_ID) {
// We didn't find a free spot - if there are any reserved areas,
// we can now test those for free space
// TODO: it would make sense to start with the biggest of them
@@ -1,3 +1,9 @@
/*
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
//! Test application that reproduces bug #4778.
@@ -43,18 +49,17 @@ area_creator(void*)
base = (void*)0x60000000;
status = _kern_reserve_address_range((addr_t*)&base, B_BASE_ADDRESS,
128 * 1024 * 1024);
if (status != B_OK)
snooze(10000000LL);
addressSpec = status == B_OK ? B_EXACT_ADDRESS : B_BASE_ADDRESS;
printf("\naddress spec = %lx, base %p (status %s)\n", addressSpec, base, strerror(status));
printf("\naddress spec = %lx, base %p (status %s)\n", addressSpec,
base, strerror(status));
}
area_id area = create_area(readOnly ? "read-only memory" : "r/w memory",
&base, addressSpec, B_PAGE_SIZE * 4, B_NO_LOCK,
B_READ_AREA | (readOnly ? 0 : B_WRITE_AREA));
if (area >= 0) {
printf("new %s area %ld at %p\n", readOnly ? "read-only" : "r/w", area, base);
// putchar('#');
printf("new %s area %ld at %p\n", readOnly ? "read-only" : "r/w",
area, base);
} else
break;