JaeguKim JaeguKim - 1 month ago 19
C Question

C programs that refer directly to a numeric address, these processes physically refer to same place?

Let's say we have compiled a C program that refer directly to a numeric address , and then executed two. So these two processes physically refer to the same place? If not, how can you refer to different physical spaces?

Answer Source

The answer depends on the hardware.

On systems with virtual memory management a process is running in its own "sandbox" with the entire memory space available to it. Multiple processes may access the same address, but virtual memory manager would give each one a separate page in physical address space, so the two processes would not "collide" over the same item in memory.

On systems without virtual memory management there is no protection: if two processes refer to the same address, they would be accessing the same location in memory.

Note: Accessing an address that has not been allocated to your program is undefined behavior. For this reason, programs that access a hardcoded addresses may be invalid.