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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6f69b1cf0f02b9ac X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-20 10:16:29 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out.usenetserver.com!cyclone-pass-sjo.usenetserver.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.sttls1.wa.home.com.POSTED!not-for-mail Reply-To: "DuckE" From: "DuckE" Newsgroups: comp.lang.ada References: <93ti8b$bjpps$1@ID-25716.news.dfncis.de> <9BP86.270637$U46.8654942@news1.sttls1.wa.home.com> <94563n$cb6kp$1@ID-25716.news.dfncis.de> Subject: Re: How can I avoid Using a Semaphore? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <0Cka6.290338$U46.9207275@news1.sttls1.wa.home.com> Date: Sat, 20 Jan 2001 18:16:28 GMT NNTP-Posting-Host: 24.6.221.63 X-Complaints-To: abuse@home.net X-Trace: news1.sttls1.wa.home.com 980014588 24.6.221.63 (Sat, 20 Jan 2001 10:16:28 PST) NNTP-Posting-Date: Sat, 20 Jan 2001 10:16:28 PST Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: supernews.google.com comp.lang.ada:4239 Date: 2001-01-20T18:16:28+00:00 List-Id: "Nick Roberts" wrote in message news:94563n$cb6kp$1@ID-25716.news.dfncis.de... > Steve, what you're doing IS dynamic run-time allocation! The only difference > is that you are doing it yourself, rather than getting Ada (or its runtime > system) to do it for you. > > In this case, the problem of buffer allocation is 'orthogonal' to the > problem of the synchronisation of tasks in passing data to one another > through a buffer queue (perhaps 'pool' would be a better name then 'queue'). > If I the data was only being referenced by one task at a time, I would agree. But to expand a little on my example, we have code that does something like: packet := NewPacketNPU( 10000 ); PutNPU( packet, value1 ); PutNPU( packet, value2 ); SendPacketTGM( port1, packet ); SendPacketTGM( port2, packet ); SendPacketTGM( port3, packet ); In this arrangement the packet is sent to three separate tasks, and may only be released when all three are no longer referencing the data. The reason I chose not to use Ada serialization, is that items are inserted into the packet in "network byte order". Unfortunately in Ada 95 the 'input and 'output attributes are pre-defined for the built in data types, so I have no control over byte ordering. I know that GNAT works around this when you use their DSA, but they do so by using a "special" version of the RTL that makes ALL streams in network byte order. In my opinion this is one of the weak points of Ada 95. It would have been better to not have the 'input and 'output pre-defined for built in types (as a part of the language) but to include a package for defining these attributes. That way an arbitrary representation of built in types could be used with streams when desired. SteveD