Page tables & TLB & System Calls
32 bit virtual address : 10 --------10 ------------12------
if paging on in processor, every pointer has to be translated to physical address.
linux will create virtual address for physical if it doen't have one
ControlRegister3 (CR3) register is base of page table
change which virtual address we're in
CR3 protected (cant' change from user mode)
thread vs process - threads share addresses
"kernel level thread" = lightweight processes = share address space
when kernel changes from one process to another, changes cr3
for any process, first-level page table exists (4kb = 2 ^ 10, but each 4 bit word, 1024 entries)
How paging works:
first 10 bits used as index into first level pg table
first level - supervisor bit, user or kernel permission, valid bit,
everything done in lazy way - kernel won't put something in memory until absolutely necessary
first level pg table is valid pointer to 2nd level pt table
get pointer out of second (if valid/accessible/etc)
VM_struct
list of all diff pieces of virtual memory
page faults
expanding stack (3 pg tolerance)
bogus ptr
mapped memory - trying to write to library example - permissions
sbrk - system call to resize heap
if mapping gone (if process hasn't used process in long time, kernel writes a page back to disk)
thrashing
os moving pages
SWAP
ext4 filesystem
precise interrupts
stack grows backwards in virtual memory in x86
//////////
Table LookAside Buffer
Replaces need to look at page table (unless page fault)
x86 has to worry about what -
have to flush it if switch to new process
virtual to physical address mappings aren't the same from process to process
some (not x86) can tag & choose to not use those TLB entries
Context Switches & System Calls
processor can give up cpu by doing system call
System Call
exception = specific to process
interrupt =
int(errupt) 0x80
paging system keeps user in 'is place!
Back to pg tables:
"Copy on Write" - when you fork child, shares everything w/ parent (binary, permissions, etc)
makes separate pg table for each child.
optimization
when parent and child write to same page, shouldn't be able to see each others' writes
perl python ruby code usable
C
process scheduling
less /proc/588/maps
look atthis to understand diff mem structures are & virtual space.
No comments:
Post a Comment