comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Lorenzen <mark.lorenzen@ofir.dk>
Subject: Re: POSIX_Generic_Shared_Memory
Date: 27 Sep 2004 22:46:34 +0200
Date: 2004-09-27T22:46:34+02:00	[thread overview]
Message-ID: <m3mzzb8mol.fsf@0x535ba173.boanxx18.adsl-dhcp.tele.dk> (raw)
In-Reply-To: 1095700990.407634.230970@k26g2000oda.googlegroups.com

"Mattias Lindblad" <ml_news@matli.net> writes:

> Hi,
> 
> I have found some problems when experimenting with the
> POSIX_Generic_Shared_Memory package. Let's start with a code example to
> illustrate my point:
> 

[example and decription removed]

> However, the client raises a Storage_Error when trying to access the
> shared data. I have found that this is because the Protection_Options
> are passed straight through to Map_Memory, and in my case this leads to
> a memory region that is write-only.
> 
> The obvious solution would of course be to set Protection_Options to
> (Allow_Write + Allow_Read). Unfortunately, by doing this the
> Open_Shared_Memory will be called with a mode of Read_Only. This feels
> a bit weird, but follows the POSIX 1003.5b standard, 12.5.1.2(1): "If
> the value of Protection is set to Allow_Write, Mode is Read_Write;
> otherwise Mode is Read_Only." (From the 1996 version, I'm afraid I
> haven't access to an updated version).
> 
> Is this really how it is supposed to work? In my opinion the standard
> text should read "If the value of Protection *includes* Allow_Write
> [...]".

The ISO/IEC 14519 standard says:

    [Open_And_Map_Shared_Memory] If the value of Protection is set to
    Allow_Write, Mode is Read_Write; otherwise Mode is Read_Only.

    [Open_Or_Create_And_Map_Shared_Memory] If the value of Protection
    is set to Allow_Write, Mode is Read_Write; otherwise Mode is
    Read_Only.

> 
> I have only tried this with GNAT 3.15p and Florist. So I don't know if
> this might be specific to this system or if it is more general.
> 
> Any ideas about this? Is it a bug in GNAT, the standard, both of them
> or none of them (i.e. I'm not doing things the way I'm supposed to)?

Looking at the source code for florist 3.5.0_20040403, it seems that
it is NOT florist, that is to blame. What version of florist do you use?

Try to look in the file posix-generic_shared_memory.adb for the two
functions you use and inspect that they contain the following statement:

      if Protection = POSIX.Memory_Mapping.Allow_Write then
         Mode := POSIX.IO.Read_Write;
      else Mode := POSIX.IO.Read_Only;
      end if;

> Thanks,
> Mattias

Regards,
- Mark Lorenzen



  parent reply	other threads:[~2004-09-27 20:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-20 17:23 POSIX_Generic_Shared_Memory Mattias Lindblad
2004-09-22 14:52 ` POSIX_Generic_Shared_Memory Paul Colin Gloster
2004-09-22 16:18   ` POSIX_Generic_Shared_Memory Mattias Lindblad
2004-09-27 20:46 ` Mark Lorenzen [this message]
2004-09-27 21:51   ` POSIX_Generic_Shared_Memory Ludovic Brenta
2004-09-29 12:09   ` POSIX_Generic_Shared_Memory Mattias  Lindblad
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox