apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Gross <ChristianGr...@yahoo.de>
Subject Some shared memory questions
Date Sun, 29 Apr 2001 02:05:04 GMT
I am starting to implement the shared memory routines on Windows.  I
have a couple of quick questions.

Lets consider the following code...

struct myStruct {
	long *ptr;
};

struct myStruct *tmpStruct;

tmpStruct = (struct myStruct *)apr_shm_malloc( ..);
tmpStruct->ptr = (long *)apr_shm_malloc( ...);

The problem here is that on Windows the tmpStruct->ptr pointer will
point to a memory segment that is only valid in the one process.  If
another process attempts to read that memory then it will fail.
Mapping data segments to specific addresses is not viable, as far as I
can see.

However with the VC++ compiler there is a compiler extension __based(
ptr) which automatically maps segments.  This solves the problem, but
it requires that the user write the structure as follows.

struct myStruct {
	long __based( base) *ptr;
};

The problem with this structure is obvious.  It is not cross-platform
compatible.

So my question is how do you deal with this situation on UNIX?  I
tried looking at the routines and sort of understand it, but could
someone please explain it to me?

Christian

Mime
View raw message