Page 1 of 1

Where do you put your kernel stack ?

Posted: Tue Jul 10, 2007 12:30 am
by nicesj
Hi,

Where do you make your stack spaces?
What address? and how much?

Re: Where do you put your kernel stack ?

Posted: Tue Jul 10, 2007 2:36 am
by urxae
sjpark wrote:Where do you make your stack spaces?
What address? and how much?
A simple way:

Code: Select all

void* new_kernel_stack = malloc(STACK_SIZE) + STACK_SIZE;
You can also use the page allocator to allocate some pages instead of using (k)malloc.
The usual size for a kernel stack is a small multiple of 4k. If you're using the page allocator you can leave a non-present page in front of it to get an exception when the stack overflows.