1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Avoid physical frame stack overflow.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-03-12 21:29:19 +01:00
parent 54e68a0c51
commit efe70b3b3e

View file

@ -239,7 +239,7 @@ namespace Sortix
{ {
// This call will always succeed, if it didn't, then the stack // This call will always succeed, if it didn't, then the stack
// wouldn't be full, and thus this function won't be called. // wouldn't be full, and thus this function won't be called.
addr_t page = Get(); addr_t page = GetUnlocked();
// This call will also succeed, since there are plenty of physical // This call will also succeed, since there are plenty of physical
// pages available and it might need some. // pages available and it might need some.
@ -350,7 +350,15 @@ namespace Sortix
void PutUnlocked(addr_t page) void PutUnlocked(addr_t page)
{ {
assert(page == AlignDown(page)); assert(page == AlignDown(page));
assert(stackused < MAXSTACKLENGTH); if ( unlikely(stackused == stacklength) )
{
if ( stackused == MAXSTACKLENGTH )
{
pagesnotonstack++;
return;
}
ExtendStack();
}
STACK[stackused++] = page; STACK[stackused++] = page;
} }