Confusing in Address

Mulyadi Santosa mulyadi.santosa at gmail.com
Sun Feb 12 06:26:23 EST 2012


Hi :)

Let me try to help ...

On Sat, Feb 11, 2012 at 16:52, hz hanks <hankshz at gmail.com> wrote:
> Hi, all
>
> I'm confused with different addresses in Linux, such as virtual
> address and hardware address.

very very likely you will deal with virtual address, because you're in
protected mode and MMU (Memory Management Unit) give you that virtual
address. It is the MMU task that translate such virtual address into
physical address with the help of page tables.

>For example, which kind of address one
> can get when using "&num" in application layer programming?

Virtual address.... precisely inside user space. Application could
only touch its own user address space, not kernel's.

>How about
> that in kernel, such as in device driver?

kernel too access virtual address. However, since there's identical
mapping for kernel address space (address 3 gigabyte and above in x86
32 bit architecture), say you are accessing address 0xC0000001, you
are actually accessing physical address 1. For 0xC0000002, it's
physical address is 2 and so on.

>Which kind of address one
> can get when using "void _ _user *to" in device driver?
same too, virtual address. But relative to which user address space we
are dealing with.

>And which kind
> of address the kernel is working with when using "mmap"?

virtual address again :)

>And which
> kind of address we are talking about when divide the memory into user
> space and kernel space?

virtual address :) in x82 32 bit, you have 4 gigabyte addressing
space. It's splitted 3 gigabyte for user space, 1 gigabyte for kernel
space.

Of course, the physical amount of RAM could be lower than 4G....


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list