shmem works static-linked, but not dynamic-linked

shmem works static-linked, but not dynamic-linked

Post by tftcons.. » Sun, 27 Feb 2000 04:00:00

Shared-memory works on static-linked by not dynamic-linked program:

I wanted to use shared-memory between 2 processes in my application.
I first tried a small test, with one Reader Process that creates and
attaches (shmget, shmat) a shared segment, and one Writer Proces that
attaches afterward. The Writer writes data into the segment, then
sets a ReadDataAvailable flag at a known location in the segment.
The Reader polls that flag, and reads the data when the flag is set.

All this works nicely when the Writer is a static-linked program.
When the Writer is packaged as a ".so" lib, then something breaks.
The Reader can still detect the ReadDataAvailable flag change state,
but when it tries to read the data, all the locations are zeros.

Note that this is EXACTLY the same program code (C) in each case;
I did check with nm and it seems that the shmget/shmat calls are
in each case invoking via GLIBC_2.0.

I suspect this is a glitch in the CPU primary or secondary cache?
The write-through is buggy? Yet it is surprising that the flag
location is written ok, and data that is only a few locations away
is lost... HELP!

I tried 2 different systems, both VALinux:
VALinux 1-CPU i386  v 2.0.36, gcc v, ld v2.9.1 (~=RedHat5.2?)
VALinux 2-CPU i386 v2.2.12-29.4 smp, (~=RedHat6.0?)
gcc egcs-2.91.66, ld v2.9.5

Sent via
Before you buy.