-
June 1st, 2012, 07:41 AM
#1
Memory Mapping in Visual C++ programming
Hi,
I am doing the memory mapping in between two processes. I used the example from Creating Named and Shared memory from MSDN. I can write and read the data in between two processes, but the problem i am facing is, in middle of this process after some time, some values are read as zero while reading from Process 2 which are written by Process 1, resulting in error in my process. Also tell me whether I have to maintain any timing in between the processes when doing Memory mapping. How to solve this memory reset problem.
Please help me in solving this problem. Will be waiting for reply.
Thank You in advance.
-
June 1st, 2012, 08:19 AM
#2
Re: Memory Mapping in Visual C++ programming
This may seem obvious, but I have to ask before continuing: are you using a mutex or semaphore to protect access to the memory? Because yes, you do indeed have to maintain timing between the processes. The OS is going to schedule your processes completely randomly (at least to you) and if something needs to happen in a certain order, you need to make sure you do that.
-
June 2nd, 2012, 01:17 AM
#3
Re: Memory Mapping in Visual C++ programming
Thank You for your reply.
Actually what i am doing is, i have Process-1 which need hardware details and Process-2 which consists of hardware details. And these details are shared in between these two processes which are available in memory using the memory mapping example from Create Named and Shared memory from MSDN library. I am not using any threads in those two processess and no mutex and no semaphore. So during this I read zero in middle after sometime which results in errors. Please let me know how to proceed further.
Thank You.
-
June 2nd, 2012, 01:29 AM
#4
Re: Memory Mapping in Visual C++ programming
Originally Posted by afroza
Please let me know how to proceed further.
We don't have your code. The error can be anything -- maybe your program has a simple bug and has nothing to do with threads or even memory mapped files.
Until we have your program, compile the code, and duplicate the error, you're the only one right now who should know how to proceed. All I can tell you is to debug your code more thoroughly.
Regards,
Paul McKenzie
-
June 2nd, 2012, 01:35 AM
#5
Re: Memory Mapping in Visual C++ programming
I have gone through the code, and i am taking log of the data where i am writing continuously 1 and reading continuously 1. In log file writes remain 1 but reading side log changing in middle from 1 to 0 and again 0 to 1.
-
June 2nd, 2012, 08:53 AM
#6
Re: Memory Mapping in Visual C++ programming
Originally Posted by afroza
I have gone through the code, and i am taking log of the data where i am writing continuously 1 and reading continuously 1. In log file writes remain 1 but reading side log changing in middle from 1 to 0 and again 0 to 1.
So how does that change the fact that we do not have your code to see what you're doing? You're asking us to magically guess what the issue is, and no one can do that without the code in hand.
Again, you need to debug further -- you have the program, code, etc. You're in a much better position to see what the problem is then anyone here.
Regards,
Paul McKenzie
-
June 4th, 2012, 09:57 AM
#7
Re: Memory Mapping in Visual C++ programming
Please edit your post. Add code tags [code]Your code here[/code] and re-indent it to make it readable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|