Where should i put the stack?
Where should i put the stack?
Having just started osdeving I am thinking about changing the stack from the temporary stack my bootloader creates. Can you just put the stack anywhere or is there a special place to put it?
Hi,
The simple answer is that you can put the stack anywhere you like (pretty much). A few considerations may be:
* As you know, the stack grows downwards - make sure it has enough space (of course, 'enough space' greatly depends on your kernel and coding style).
* If you are using paging, leave a free page between your stack and heap. If your kernel gets bigger and the stack starts corrupting data, it could be very difficult to find the cause.
I believe that one of the conventions is having the stack immediately above the heap. I tend to follow this convention, but do leave that free page so that you get a page fault exception if the stack gets too big.
Cheers,
Adam
The simple answer is that you can put the stack anywhere you like (pretty much). A few considerations may be:
* As you know, the stack grows downwards - make sure it has enough space (of course, 'enough space' greatly depends on your kernel and coding style).
* If you are using paging, leave a free page between your stack and heap. If your kernel gets bigger and the stack starts corrupting data, it could be very difficult to find the cause.
I believe that one of the conventions is having the stack immediately above the heap. I tend to follow this convention, but do leave that free page so that you get a page fault exception if the stack gets too big.
Cheers,
Adam