Refactor stack growth #57
@@ -5,14 +5,16 @@
|
||||
#include "threads/vaddr.h"
|
||||
#include "userprog/pagedir.h"
|
||||
|
||||
#define MAX_STACK_ACCESS_DIST 32
|
||||
|
||||
/* Validates a given address for being <=32 bytes away from the stack pointer or
|
||||
above the stack */
|
||||
bool needs_new_page (void *addr, void *esp)
|
||||
{
|
||||
return (is_user_vaddr (addr) &&
|
||||
(uint32_t*)addr >= ((uint32_t*)esp - 32) &&
|
||||
((PHYS_BASE - pg_round_down (addr))
|
||||
<= MAX_STACK_SIZE));
|
||||
(uint32_t*)addr >= ((uint32_t*)esp - MAX_STACK_ACCESS_DIST) &&
|
||||
((PHYS_BASE - pg_round_down (addr))
|
||||
<= MAX_STACK_SIZE));
|
||||
}
|
||||
|
||||
/* Extends the stack by the necessary number of pages */
|
||||
|
||||
Reference in New Issue
Block a user