Quote:
Originally Posted by
dragonpoint
If user space heap and kernel space heaps are diff, can the allocated kernel/ user areas be accessed by mapping in either case all times?
Heap isn't a special kind of memory, even to the process. It's all just memory as far as they're concerned. Take a look at
The Paging Game to get a rough idea of what virtual memory does.
But it's not exactly direct. User space sees its own memory as a flat memory space but it's not: It's organized in 4K chunks in no particular order and might even be on disk, not in memory, when asked for. It's the kernel's job to keep that mess straight.
The kernel almost never reaches into process space to extract data without being told to do so. That's what read() and write() calls do when you think about it -- tell the kernel what areas of user memory to extract from, or to write into, for some operation or other. Once it's been told, copy_to_user and copy_from_user calls translate memory in and out of user space. Otherwise, the kernel's job is mostly set things up and let them happen in userspace.