lkml.org 
[lkml]   [2009]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: Kernel vs user memory
From
On Fri, Jan 16, 2009 at 11:21 PM, sidc7 <siddhartha.chhabra@gmail.com> wrote:
>
> I am not an expert, just started doing some kernel programming and code
> reading, so as far as I understand, memory can be either mapped to user
> space or kernel space, if its neither in user and kernel, as you said, the
> division is not easy, where will the memory be mapped to, is there any other
> special region ?

For each memory space (usually one per process), the kernel sets up a
page table. The lower PAGE_OFFSET bytes are mapped differently for
each such space, but above the address PAGE_OFFSET, every process has
the same mappings - this is what one usually thinks of when one hears
'kernel memory'. The kernel then puts its data structures in this
upper area, so that the addresses of these structures remains the same
in all processes. Of course, these pages are only accessible in kernel
mode - attempting to access them at all from a user process will get
you a segmentation fault.

Note also that while on 64-bit platforms the kernel memory map
generally includes all of physical RAM, on 32-bit platforms such as
the x86, there's typically only about 700mb of physical RAM mapped in
this area by default; the remainder of RAM (if any) can only be used
for page/buffer cache and process memory.


\
 
 \ /
  Last update: 2009-01-17 06:29    [W:0.590 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site