Where do you put your kernel stack ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
nicesj
Member
Member
Posts: 27
Joined: Fri May 06, 2005 11:00 pm
Location: South Korea
Contact:

Where do you put your kernel stack ?

Post by nicesj »

Hi,

Where do you make your stack spaces?
What address? and how much?
http://nicesj.com
With the software, What You Think Is What You Get.(WYTIWYG)
urxae
Member
Member
Posts: 149
Joined: Sun Jul 30, 2006 8:16 am
Location: The Netherlands

Re: Where do you put your kernel stack ?

Post 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.
Post Reply