+#include <stdio.h>
+#include <string.h>
+#include "threads/init.h"
+#include "threads/loader.h"
+#include "threads/mmu.h"
+#include "threads/synch.h"
+
+/* Page allocator. Hands out memory in page-size chunks.
+ See malloc.h for an allocator that hands out smaller
+ chunks.
+
+ System memory is divided into two "pools" called the kernel
+ and user pools. The user pool is for user (virtual) memory
+ pages, the kernel pool for everything else. The idea here is
+ that the kernel needs to have memory for its own operations
+ even if user processes are swapping like mad.
+
+ By default, half of system RAM is given to the kernel pool and
+ half to the user pool. That should be huge overkill for the
+ kernel pool, but that's just fine for demonstration purposes.
+
+ Within each pool, we simply use a linked list of free pages.
+ It would be straightforward to add all available memory to
+ this free list at initialization time. In practice, though,
+ that's really slow because it causes the emulator we're
+ running under to have to fault in every page of memory. So
+ instead we only add pages to the free list as needed. */