On Mon, Jul 01, 2002 at 11:49:13AM -0600, Erik Andersen wrote:
> void *malloc(size_t size)
> {
> void *result;
> if (size == 0)
> return NULL;
> result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE,
> MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
> if (result == MAP_FAILED)
> return 0;
> * (size_t *) result = size;
> return(result + sizeof(size_t));
> }
This looks like a very bad idea. Userspace allocators should make some
attempt at avoiding diving into the kernel at every allocation like this.
Also, they should be intelligent enough to get around TASK_UNMAPPED_BASE.
Wilson's allocator survey has an excellent discussion of the issues.
Doug Lea has a better example of a userspace memory allocator.
Cheers,
Bill
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sun Jul 07 2002 - 22:00:09 EST