All physical memory is mapped into virtual address of kernel? -
i studying device driver recently, , reminded of concepts of virtual memory. although attended computer architecture classes when student, however, speaking, virtual memory complicated concepts confused me. ee guy, so, please explain view of big picture distinguish concept. can dig technique details myself.
when talking virtual memory, talking memory allocation method process. process 1 virtual memory serves, right? 32-bit system 4gb address space, 0-3g assigned user space virtual address, , 3-4g space assigned kernel. called 3g/1g division, post listed below:
http://users.nccs.gov/~fwang2/linux/lk_addressing.txt
however, post illustrated all physical memory mapped kernel space, , nothing user space. confused me. list part in post here:
#thus, in 3g/1g split, kernel has virtual address space of 1gb. remember access physical address, need virtual address start with, kernel. if don't special, 1gb virtual address limits physical space kernel can access 1gb. okay, maybe third less obvious detail: kernel needs access every physical memory make full use of it.
in days, machine's physical space less 1gb, ok, whole physical memory mapped 1gb virtual address.
process address space 4gb +---------------+ | 512mb | +---------------+ <------+ physical memory | 512mb | | 3gb +---------------+ <--+ +---> +------------+ | | | | 512 mb | | ///// | +-------> +------------+ | | 0gb +---------------+
# and post illustrate same thing when physical memory above 2g:
# physical mem process address space +------> +------------+ | | 3200 m | | | | 4gb +---------------+ <-----+ | high mem | | 128 mb | | | +---------------+ <---------+ | | +---------------+ <------+ | | | | 896 mb | | +--> +------------+ 3gb +---------------+ <--+ +-----> +------------+ | | | | 896 mb | | ///// | +---------> +------------+ | | 0gb +---------------+
# my questions is, why physical memory mapped kernel space? none lower 0-3g user space?
i think missed related big picture behind post, but, have missed?
thanks time , efforts!
a page has mapping does not
automatically mean lying somewhere in physical memory. merely gives address of where page
in physical memory.
in case, typically have memory heirarchy. 3 level hierarchy not atypical these days. given memory address found in 1 of these caches. if isn't kernel have start it's page replacement algorithm evicting (unlocked) pages memory.
the difference between user , kernel pages, afaik, kernel pages have "higher" privileged code allowing access privileged instructions , in case of 32bit linux kernel portion of given process have fixed virtual address space not change between process context switches. , simplify , therefore fasten translation physial address, mapping fixed pre-configured offset. other there isn't difference between user space page , kernel space page. both of them "compete" physical memory.
in case, scheduler determines entity run next, whether regular user space process, kernel control path (piggybacking on current process) or kernel thread. depending on decision, swapper swap out pages ram make room , swap in pages chosen entity.
an interrupt has altogether different context bypassing scheduler leaving cpu @ it's mercy. in case isr run access virtual memory. if pages corresponding isr not resident in memory, double fault occur , shows poor programming author. how these handled vary architecture architecture. process fault until point, throw kernel oops message , halt. nevertheless, relevant question here isrs have highest priority in system (way above processes/threads) have make sure there enough memory job.
p.s: in discussion assuming our cache requests miss have go way ram (which again packed full).
Comments
Post a Comment