简体   繁体   中英

Process virtual address space and kernel address space? How?

I am very new to kernel or system programming,

I have couple of questions related to virtual memory. Mostly related to static vs run time, [ie ELF and loading/Linking etc], Specific to linux-x86.

My understandings might be completely wrong...

I am aware of virtual memory and it's split 1G/3G. where process can not access address above PAGE_OFFSET in user mode - PAGE_OFFSET is virtual address.

At Static time ELF defines process Virtual space?

  1. If ELF defines virtual address space then does ELF also defines kernel virtual address space? How? [ I assume kernel virtual address space is dynamically mapped at run time?]

  2. If kernel address space is mapped to process address space then why doesn't process size(virtual) includes kernel size also?

    • When and How this kernel address space is mapped/linked? Like , In case of shared library the particular file is pointed by vm struct etc..
    • Is it when code flow hits system call? For example.
  3. Does executable size determines process size (virtual) completely? in what context sizes differ or they are completely different.

Any article that explains overall flow?

Compile --> link/load --> virtual memory structure (kernel address space/shared objects etc)

I know its very vast but explanation on overall flow will work.

Most systems define logical address ranges for kernel and user address spaces. On some systems the range is entirely up to the operating system (how it sets up the page tables) on others it is done in hardware.

For the former, page tables are usually nested. In which case multiple page tables share identical entires.

For the latter, there are usually separate page tables for the user and kernel address spaces.

If ELF defines virtual address space then does ELF also defines kernel virtual address space? How? [ I assume kernel virtual address space is dynamically mapped at run time?]

The executable file only defines the initial layout of the user address space.

If kernel address space is mapped to process address space then why doesn't process size(virtual) includes kernel size also?

That would depend upon the system and how it does the counting.

When and How this kernel address space is mapped/linked? Like , In case of shared library the particular file is pointed by vm struct etc.

The kernel address space exists independent of any processes. As mentioned above, it is mapped to a process either by having a system page table shared by all processes or a set of nested page table entries shared by all processes.

Does executable size determines process size (virtual) completely? in what context sizes differ or they are completely different.'

Not really. Large executables are indicative of larger ranges of logical addresses required. However, a small EXE can easily describe a large number of demand zero pages. In addition, the application can map logical pages as it executes. The EXE only defines the initial state of the logical address space.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM