Memory Management Unit (Memory Virtualization)
8-bit addressing
– Address space: 256 Bytes
– Page size: 4 Bytes
– PTE: 1 Byte

PTE
– Unmapped PTE is filled with zeros
– Swap space: 512 Bytes (=27 * 4 Bytes)
– Offset starts from 1
• 0th page in swap space is not used
– Present bit is 0
• Commend
$ my_cpu <input_file> <pmem_size> <swap_size>
void *my_mmu_init (unsigned int mem_size, unsigned int swap_size)
– mem_size: physical memory size in bytes
• allocate a memory space and manage alloc/free lists
– swap_size: swap disk size in bytes
• Allocate a memory space instead of real disk space
• manage alloc/free lists
– Return value
• Pointer (i.e., address) to the allocated memory area that simulates the physical memory
• 0: fail
int my_run_proc (char pid, struct my_pte **my_cr3)
– Performs context switch
• If pid is new, the function creates a process (i.e., PCB) and its page table
– pid: pid of the next process
– my_cr3: stores the base address of the page table for the current process
– Return value
• 0: success
• -1: fail
int my_page_fault (char pid, char va)
– Handling a page fault caused by demand paging or swapping
• Page replacement policy: FIFO
– Managing swap space
• Alloc/free lists
– pid: process id
– va: virtual address
– Return value
• 0: success
• -1: fail