comp.lang.ada
 help / color / mirror / Atom feed
From: awdorrin <awdorrin@gmail.com>
Subject: Re: POSIX.Semaphores question
Date: Mon, 5 Dec 2011 08:58:55 -0800 (PST)
Date: 2011-12-05T08:58:55-08:00	[thread overview]
Message-ID: <8fbf5f51-f133-41bf-9457-b3f85e3950c9@x7g2000yqb.googlegroups.com> (raw)
In-Reply-To: 4edcd2fa$0$6548$9b4e6d93@newsspool4.arcor-online.net

On Dec 5, 9:19 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
> On 05.12.11 13:25, awdorrin wrote:
>
> > The only thing I do see, is when I add the compile flat to print out
> > the rep specs - the Semaphore is given two different sizes...
>
> > for SEM_R_RTSIM_SHM_READY'Size use 128;
> > for SEM_R_RTSIM_SHM_READY'Size use 192;
>
> > It should be 128, not sure why its later showing as 192... from
> > looking at the definition for sem_t on this linux system, it should be
> > 128.
>
> That's odd. Is this really the same variable (or maybe just
> the same name)?

It looks like when I check the spec file (with a -gnatc) it shows the
size as '128' - but when I compile, it shows it as '192' - when I
check it with the debugger, it is 24 bytes/192 bits, not sure why
there is a discrepancy.


> FWIW, the following program appears to be working as expected,
> in at least one environment.
>

Thanks for your example - I build another test case using an Ada only
program - and the Semaphore_Descriptors were getting set fine,
although I did run into an odd problem...

I wanted to try and print out the address of the Semaphore_Descriptor
variable and the address to which it was pointing.
I tried the following line:

Text_IO.Put_Line( System.Address_Image(SemPtr'Address) & " -> " &
System.Address_Image(SemPtr.all'Address) );

The first Address_Image worked fine, but I could never get the second
to compile, I kept seeing the error:
"prefix of dereference must be an access type"

SemPtr is a Semaphore_Descriptor, which is defined as: type
Semaphore_Descriptor is access constant POSIX.C.sem_t;
I'm not sure if this is related to the GNAT bug reported here:
http://patchwork.ozlabs.org/patch/112485/

In any case, I went back to my original code and investigated further
and I think I figured out the problem...

I discovered that some of the Semaphore_Descriptors being exported
were working fine, while others were not.
Turns out it had to do with the export statement:

pragma export( C, SEM_PTR1, "SEM_PTR1"); -- does NOT work
pragma export( C, SEM_PTR2, "sem_ptr2"); -- DOES work

Apparently the export has to have the link name in lower case... Not
sure I understand why this is the case...
Of course I still don't understand how the convention (C vs Ada)
effects the export pragmas either :)

Program is getting a lot further now that the semaphores are working
properly!





  reply	other threads:[~2011-12-05 17:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-02 15:43 POSIX.Semaphores question awdorrin
2011-12-02 16:54 ` awdorrin
2011-12-02 17:06   ` Georg Bauhaus
2011-12-02 17:09     ` Georg Bauhaus
2011-12-02 17:22       ` awdorrin
2011-12-03 16:32         ` awdorrin
2011-12-03 19:59 ` Niklas Holsti
2011-12-05 12:25   ` awdorrin
2011-12-05 14:19     ` Georg Bauhaus
2011-12-05 16:58       ` awdorrin [this message]
2011-12-05 17:59         ` Simon Wright
2011-12-06  0:53           ` awdorrin
replies disabled

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