apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@covalent.net>
Subject Re: Some shared memory questions
Date Sun, 29 Apr 2001 02:08:41 GMT

Shared memory is completely wrong in APR right now.  We talked about how
to fix it at the hack-a-thon, and I have notes.  I will try to post them
this weekend so that everybody know how we are re-implementing it.

Ryan

On Sat, 28 Apr 2001, Christian Gross wrote:

> 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
>
>


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Mime
View raw message