arena: allow "self-sourced" arenas
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 2 Oct 2019 16:52:10 +0000 (12:52 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 8 Oct 2019 21:11:11 +0000 (17:11 -0400)
commita4708521d495ae3c9086a38e6241aa984953f684
tree65baa305fcb45d623b6437376d16590430997807
parent04266733eeeabe6b03ca4f3fa39a256f8c59249b
arena: allow "self-sourced" arenas

These arenas generate their own resources dynamically and arbitrarily.
They do not source from another arena, such as base, but they also are
not given their segments in advance with arena_add().  Instead, they
create resources when asked.

It is similar to calling arena_add() in response to a failed allocation,
except the allocation never fails.

The arena alloc function pointer lets you do whatever you want.  The
reason for self-sourcing instead of pulling from a dummy arena is that
the self-source provides a pointer to the arena in the allocation
function.  With that pointer, you now have your original arena, which
could be embedded in another structure.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/drivers/dev/mem.c
kern/include/arena.h
kern/src/arena.c
kern/src/ktest/kt_arena.c