df7096a4aa
waiting for a heap grow. * Use that nogrow version in the VM code to avoid a deadlock with the address space lock when a grow operation would try to create an area while a malloc happened from such a function in the VM. * When waiting for a grow to happen, notify the waiting thread from the grower also if it failed to allocate a new heap. Otherwise a thread would just sit there and wait until another thread requested growing too and that one succeeded (or just forever in the worst case). * Make the dedicated grow heap growable too. If the current grow heaps run low on memory it will instruct the grower to allocate a new grow heap. This reduces the likelyhood of running out of memory with no way to grow to a minimum. As the growing is done asynchronously it is still possible to happen, but it is highly unlikely as the grow heap is solely used to allocate memory in the process of creating new heap areas and it will even try using normal public memory if the dedicated memory has run out. * Reduced the dedicated grow heap from 2 to 1MB. As it can now grow itself, it doesn't need to last so long. * Extract heap creation into it's own function that does area creation and heap attach and use this function for growing normal and grow heaps. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26009 a95241bf-73f2-0310-859d-f6bbb57e9c96
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/*
|
|
* Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
|
* Distributed under the terms of the NewOS License.
|
|
*/
|
|
#ifndef _KERNEL_HEAP_H
|
|
#define _KERNEL_HEAP_H
|
|
|
|
#include <OS.h>
|
|
|
|
// allocate 16MB initial heap for the kernel
|
|
#define INITIAL_HEAP_SIZE 16 * 1024 * 1024
|
|
// grow by another 8MB each time the heap runs out of memory
|
|
#define HEAP_GROW_SIZE 8 * 1024 * 1024
|
|
// allocate a dedicated 1MB area for dynamic growing
|
|
#define HEAP_DEDICATED_GROW_SIZE 1 * 1024 * 1024
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// malloc_nogrow disallows waiting for a grow to happen - only to be used by
|
|
// vm functions that may deadlock on a triggered area creation
|
|
void *malloc_nogrow(size_t size);
|
|
|
|
void *memalign(size_t alignment, size_t size);
|
|
|
|
void deferred_free(void* block);
|
|
|
|
void* malloc_referenced(size_t size);
|
|
void* malloc_referenced_acquire(void* data);
|
|
void malloc_referenced_release(void* data);
|
|
|
|
status_t heap_init(addr_t heapBase, size_t heapSize);
|
|
status_t heap_init_post_sem();
|
|
status_t heap_init_post_thread();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _KERNEL_MEMHEAP_H */
|