Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual Memory Mohammad H. Mofrad February 23, 2016

Similar presentations


Presentation on theme: "Virtual Memory Mohammad H. Mofrad February 23, 2016"— Presentation transcript:

1 Virtual Memory Mohammad H. Mofrad February 23, 2016 1hasanzadeh@cs.pitt.edu

2 Contents Paging Hello World Kernel Module 2

3 Operating System Memory Management Segmentation A segment is a contiguous part of memory (code, stack and heap) Segment : (Base Address) + (Bound or size) - Space fragmentation Paging Split up physical into fixed sized pieces called pages View physical memory as an array of fixed-sized slots called page frames + Flexible + Simple 3Operating Systems : Three Easy Pieces

4 Page Table A per process data structure for mapping virtual addresses (VA) to physical addresses (PA) Rule: Address translation from virtual address to physical address 4Operating Systems : Three Easy Pieces OS --------------- Unused --------------- 1 st Page --------------- 3 rd page --------------- Unused --------------- 2 nd page

5 Address Translation [ [Virtual Page Number (VPA)] [Offset] ] VA => PA Decimal => Binary 21 => 010101 VPA | Offset [0 1 | 0 1 0 1] 5Operating Systems : Three Easy Pieces

6 Legacy Mode - 4KB Page Translation (With PAE) [ ----------------------------------------------------------------------------------------------------------------] | 31 30|29 21| 20 12 | 11 0| [ Page Directory Pointer Offset | Page Directory Offset | Page Table Offset | Page Offset] |31 5 | 4 0 | CR3 [ Page Directory Pointer Base | ] 6AMD64 Architecture Programmer’s Manual Volume 2: System Programming ---------- PDPE ---------- ---------- PDE ---------- ---------- PTE ---------- ---------- Physical Address ---------- 2 9912 Page Directory Pointer Table Page Directory Table Page Table 4KB Physical Table

7 Hello World Kernel Module 7Linux Device Driver #include MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); } module_init(hello_init); module_exit(hello_exit); hello.c LINUX_KERN=/usr/src/kernels/$(shell uname -r) obj-m := hello.o all: $(MAKE) -C $(LINUX_KERN) M=$(PWD) modules clean: $(MAKE) -C $(LINUX_KERN) M=$(PWD) clean Makefile insmod hello.ko % Insert module rmmod hello.ko % remove module insert/remove

8 Useful References [1] Jonathan Corbet et al. “Linux Device Driver”, 2005 [2]Remzi H. Arpaci-Dusseau et al. “Operating Systems: Three Easy Pieces”, 2015 [3]AMD64 Technology “AMD64 Architecture Programmer’s Manual Volume 2: System Programming”, 2015 [4]Thomas W. Barr et al. “Translation Caching: Skip, Don’t Walk (the Page Table)”, ACM SIGARCH Computer Architecture News, 2010 8


Download ppt "Virtual Memory Mohammad H. Mofrad February 23, 2016"

Similar presentations


Ads by Google