LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic understanding of physical memory access

The value of x at the end of these lines is zero, why isn't it 'a'?

 

char x, c='a';

ReadFromPhysicalMemory((unsigned int)&c, &x, 1);

 

 

0 Kudos
Message 1 of 7
(3,887 Views)

Well... yes. &c is actually the address in virtual memory. and ReadFromPhysicalMemory uses actual memory addresses.

is there a way I can find out the physical address from a virtual one? in other words, can I find out the physical address of c in the above example?

 

Thanks.

0 Kudos
Message 2 of 7
(3,874 Views)

Well, modern CPUs have extra hardware ( the MMU) to translate virtual addresses to physical adresses. Setting up the MMU is one basic task of the OS and you have to program at OS kernel level to do that. So I don't think that't possible within Labwindows/CVI. I think you have to look into the kernel device driver development environment for your OS to get an API for the mapping between physical and virtual addresses.   

0 Kudos
Message 3 of 7
(3,862 Views)

Uff... I hoped there is a quick and easy solution for this. 

 

The problem is that if I use MapPhysicalMemory I have to specify the address myself.

I want to be able to know the physical address (as in the case when MapPhysicalMemory is used) but have the compiler select a vacant one for me. Is there a way to do that?

0 Kudos
Message 4 of 7
(3,859 Views)
What are you trying to do that requires knowledge of physical memory addresses? There are very few circumstances that require it, and we may be able to help you better if we knew what you were trying to achieve.
--
Martin
Certified CVI Developer
0 Kudos
Message 5 of 7
(3,839 Views)

Frankly I'm just playing around, trying to figure out and expend the boundaries of my programming skills.

Let's say for example that I want several different applications to communicate directly through a word in memory.

Now I can of course use the physical memory library functions, but they all need me to come up with an address.

I don't know if the addresses that I come up with are available.

 

Thanks for your help so far, would love to hear what you think.

 

 

0 Kudos
Message 6 of 7
(3,828 Views)
There is no need to use physical addresses to communicate with shared memory. Have a look at <http://msdn.microsoft.com/en-us/library/aa366551(VS.85).aspx>
Message 7 of 7
(3,809 Views)