When I am using a pointer in C for a PC program, does it point to the physical or virtual address of the variable ?
int x = 10;
int* ptr = &x;
A pointer is an address that provides a translation within some virtual address space to a piece of physical memory. DTrace executes your D programs within the address space of the operating system kernel itself.
Yes, it's definitely possible for the same address to map to different physical memory depending on the process that's referencing it. This is in fact the case under Windows. Show activity on this post. Each process has a address space of 4GB in a 32 bit system.
It is a virtual address generated by the CPU while a program is running. It is referred to as a virtual address because it does not exist physically. Using this address, the CPU access the actual address or physical address inside the memory, and data is fetched from there.
The run time mapping between Virtual address and Physical Address is done by a hardware device known as MMU. In memory management, the Operating System will handle the processes and move the processes between disk and memory for execution .
It depends.
If you're writing a application that will run on top of a operating system, that is, in user mode and the operating system uses virtual memory, it will point to a virtual address (or rather, it will point to a physical address but not the same physical address that will in fact be used).
If you're using an operating system without virtual memory or if you're writing (parts) of the kernel code it will point to the physical address.
It depends on your OS!
In Windows and Linux it's typical virtual memory! Also user space application canno't access the memory using physical addresses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With