From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9277635655f37412 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.16.106 with SMTP id f10mr23335686pbd.8.1323104453239; Mon, 05 Dec 2011 09:00:53 -0800 (PST) Path: lh20ni72649pbb.0!nntp.google.com!news2.google.com!postnews.google.com!x7g2000yqb.googlegroups.com!not-for-mail From: awdorrin Newsgroups: comp.lang.ada Subject: Re: POSIX.Semaphores question Date: Mon, 5 Dec 2011 08:58:55 -0800 (PST) Organization: http://groups.google.com Message-ID: <8fbf5f51-f133-41bf-9457-b3f85e3950c9@x7g2000yqb.googlegroups.com> References: <9jvdbkFdi2U1@mid.individual.net> <2166814f-4a26-4425-965f-2c6215eeedde@d17g2000yql.googlegroups.com> <4edcd2fa$0$6548$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: 192.91.171.36 Mime-Version: 1.0 X-Trace: posting.google.com 1323104453 23095 127.0.0.1 (5 Dec 2011 17:00:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 5 Dec 2011 17:00:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x7g2000yqb.googlegroups.com; posting-host=192.91.171.36; posting-account=YkFdLgoAAADpWnfCBA6ZXMWTz2zHNd0j User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) Xref: news2.google.com comp.lang.ada:14840 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-12-05T08:58:55-08:00 List-Id: On Dec 5, 9:19=A0am, Georg Bauhaus 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!