|
Home > Archive > Unix Programming > July 2006 > System V IPC: shared memory, different data
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
System V IPC: shared memory, different data
|
|
| lennert.acke@gmail.com 2006-07-26, 7:28 pm |
| Hey,
I have 2 processes communicating to eachother by means of System V IPC
methods: semaphores, message queues and shared memory. Yesterday,
everything seemed to be working quite ok. Now I have the problem that
the data read by process 2 of the shared memory is NOT the same as the
data put there by process 1. Both processes share the same shared
memory id and no segfaults are generated. The data read by process 2 is
just not the same as the one in process 1, so I guess there's a funny
thing going on in the kernel, where my supposedly shared memory gets
mapped into different physical places.
Where should I start looking to solve this problem ? I've been looking
over and altering the code for a day now ...
Any help appreciated !
Lennert.
| |
| Mikko Rauhala 2006-07-26, 7:28 pm |
| On 26 Jul 2006 16:20:37 -0700, lennert.acke@gmail.com <lennert.acke@gmail.com>
wrote:
> I have 2 processes communicating to eachother by means of System V IPC
> methods: semaphores, message queues and shared memory. Yesterday,
> everything seemed to be working quite ok. Now I have the problem that
> the data read by process 2 of the shared memory is NOT the same as the
> data put there by process 1.
Just checking, but when you say you're using semaphores, I'd like to
make sure that you mean that you're at least synchronizing the shared
memory accesses using one. Funky things can happen eg. with per-cpu
caches if you don't, even if you do atomic access.
--
Mikko Rauhala - mjr@iki.fi - <URL:http://www.iki.fi/mjr/>
Transhumanist - WTA member - <URL:http://www.transhumanism.org/>
Singularitarian - SIAI supporter - <URL:http://www.singinst.org/>
| |
| Barry Margolin 2006-07-26, 7:28 pm |
| In article <slrnecg0j6.qth.mjr@sbz-30.cs.Helsinki.FI>,
Mikko Rauhala <mjr@iki.fi> wrote:
> On 26 Jul 2006 16:20:37 -0700, lennert.acke@gmail.com <lennert.acke@gmail.com>
> wrote:
>
> Just checking, but when you say you're using semaphores, I'd like to
> make sure that you mean that you're at least synchronizing the shared
> memory accesses using one. Funky things can happen eg. with per-cpu
> caches if you don't, even if you do atomic access.
Also, make sure the shared memory is declared volatile. Otherwise, the
compiler may optimize away some of the memory fetches, because it thinks
there's no way the variable could have changed.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
| |
| lennert.acke@gmail.com 2006-07-26, 7:28 pm |
|
Mikko Rauhala wrote:
> On 26 Jul 2006 16:20:37 -0700, lennert.acke@gmail.com <lennert.acke@gmail.com>
> wrote:
>
> Just checking, but when you say you're using semaphores, I'd like to
> make sure that you mean that you're at least synchronizing the shared
> memory accesses using one. Funky things can happen eg. with per-cpu
> caches if you don't, even if you do atomic access.
>
> --
> Mikko Rauhala - mjr@iki.fi - <URL:http://www.iki.fi/mjr/>
> Transhumanist - WTA member - <URL:http://www.transhumanism.org/>
> Singularitarian - SIAI supporter - <URL:http://www.singinst.org/>
I am using a semaphore set containing one semaphore to control access
to the shared memory segment. That's the only reason I use semaphores.
I am developing on a dual core CPU.
| |
| struggle 2006-07-27, 1:27 pm |
|
lennert.acke@gmail.com wrote:
> Mikko Rauhala wrote:
>
> I am using a semaphore set containing one semaphore to control access
> to the shared memory segment. That's the only reason I use semaphores.
> I am developing on a dual core CPU.
I think put your code here will help us to find the question !
| |
| lennert.acke@gmail.com 2006-07-27, 1:27 pm |
| struggle wrote:
> I think put your code here will help us to find the question !
OK. This should make things more visible:
the client: http://pastebin.ca/102357
the server: http://pastebin.ca/102360
I only included the most relevant code ... Please nevermind the
ugliness of the server code, I still need to clean it up.
I still have no idea what's going wrong :-s
|
|
|
|
|