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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!logbridge.uoregon.edu!newsfeed.stanford.edu!sn-xit-02!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: CTips Newsgroups: comp.lang.ada,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Wed, 09 Mar 2005 00:46:08 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <112t3de6fu04f38@corp.supernews.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <112rs0bdr2aftdf@corp.supernews.com> <1inxxr988rxgg$.1w9dedak41k89.dlg@40tude.net> <112s1r0rf0o8nca@corp.supernews.com> <112sonip5v4dca6@corp.supernews.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com Xref: g2news1.google.com comp.lang.ada:8908 comp.realtime:1100 comp.software-eng:4657 Date: 2005-03-09T00:46:08-05:00 List-Id: Jim Rogers wrote: > CTips wrote in > news:112sonip5v4dca6@corp.supernews.com: > > >>Martin Dowie wrote: >> >>>CTips wrote: >>> >>> >>>>Will that generate: >>>> L0: >>>> lwlock temp,&Value >>>> add temp,temp,1 >>>> stwcond temp,&Value >>>> if( failed ) goto L0; >>>>or will it generate something much more heavy-weight. >>> >>> >>>If you need that particular assembler then you'd best write it >>>yourself. I don't know of any language that could guarentee what >>>assembler is produced following a compilation. >>> >>>Cheers >>> >>>-- Martin >> >>But isn't it interesting that Ada can't express this? >> >>Roughly speaking, Ada provides synchronous message passing and >>(non-nested?) monitors as first class constructs. This means that >> - it doesn't support asynchronous communication >> - it doesn't support any number of lock-free algorithms >>Also, Ada's only scheduling/queing discipline is FIFO with priorities >>(and priorities are only available if the RT annex is actually >>implemented). If I want to do earliest-deadline first, well, how do I >>go about doing it? > > > I think you are missing some Ada capabilities. > While Ada does provide synchronous message passing and monitors, > it also provides the ability to declare objects as atomic and > volatile. > > Atomic objects can be used instead of monitors (what Ada calls > protected objects) for inter-task communication. You can then > define your own schemes including lock-free algorithms or > dcl. No you can't. How do you think atomicity is guaranteed (in general)? By providing a lock for the atomic object! Try and write code in Ada on a machine that supports either CAS or lwlock/stwcond to do an atomic increment that can generate the optimal code. > If you want different scheduling policies you write them, just as > in C or C++. Right - and then what's the advantage of the built-in features of Ada over and > How, using C or C++, would you create a threaded program and > ensure that signals are handled by a specified thread, and not > simply by the thread that is currently running when the signal > is received? What do you mean "handled by a thread"? How can you distinguish which thread is actually interrupted? More importantly, why do you care? [If you're using pthreads, the answer is that about the only way you can make out that there is a difference is by looking at thread private data, and you want to use pthread_kill() to deliver a signal to a specific thread, or see below] > How will you handle general OS signals in this > manner and not only the specialized signals provided by > pThreads? Again you're assuming that C thread library == pthreads. And OS == POSIX-compliant. There are alternate OSes and mechanisms. Also POSIX signals are process oriented, not thread oriented, so they, in my opinoin, are kind of broken. However, in POSIX, you can do it by using pthread_sigmask() to disable delivery of the signal to all threads other than the handling one. > You seem to assume that Ada only allows you to use features > provided by the language while preventing you from creating > your own features. That idea just doesn't make any sense. Nope, I didn't say that - what I said was that Ada (particularily the concurrent part of Ada) is fairly retarted, particularily if you want to get performance. In fact, to get the performance similar to that which can be obtained in C, one would pretty much have to write in the C subset of Ada [i.e. turn off most of the checking, use libraries written in C + asm]. And even there I'd have my doubts - given the additional features that Ada compilers have to deal with, I doubt that they would have focused as much on the optimizations. Actually, I can verify that: if I look at the computer shootout http://shootout.alioth.debian.org/great/, I find that gcc C beats gnat Ada pretty much across the board; actually, Ada's performance sucks pretty much across the board. One of gcc C or Intel C is generally among the top few programs, while with a couple of exceptions, Gnat Ada is around the middle. In matrix multiply it gets beaten by LISP, Java, and Python!!! (How can you get beaten by Python? The mind boggles!) > Linked lists are not implemented as native syntax in either > Ada or C, yet they are used frequently in both languages. > How can that be? And their C implemenations are faster. > Jim Rogers >