Skip to content

eigenkyeong/MMU

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MMU

Memory Management Unit (Memory Virtualization)

Addressing

8-bit addressing

– Address space: 256 Bytes
– Page size: 4 Bytes
– PTE: 1 Byte
image

PTE

PTE image           – Unmapped PTE is filled with zeros

image           – Swap space: 512 Bytes (=27 * 4 Bytes)
          – Offset starts from 1
              • 0th page in swap space is not used
          – Present bit is 0


my_cpu.c

• Commend

$ my_cpu <input_file> <pmem_size> <swap_size> 

Initialization

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

Context Switch

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

Page Fault Handling

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

About

Memory Virtualization

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages