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-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!club-internet.fr!feedme-small.clubint.net!feeder1-1.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 15 Sep 2009 13:18:07 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Grand Central Dispatch (GCD) References: <26891b3c-d828-4b02-8280-2dc1f8fdc803@31g2000vbf.googlegroups.com> In-Reply-To: <26891b3c-d828-4b02-8280-2dc1f8fdc803@31g2000vbf.googlegroups.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Message-ID: <4aaf77f0$0$31862$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 15 Sep 2009 13:18:08 CEST NNTP-Posting-Host: be6330bf.newsspool3.arcor-online.net X-Trace: DXC=HJ5EIgBn2H>i6K;>iZ]763McF=Q^Z^V384Fo<]lROoR1^YC2XCjHcb9XJ]ooN3Z`k2;9OJDO8_SK6NSZ1n^B98i:ZfB[;o;gbG0 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8329 Date: 2009-09-15T13:18:08+02:00 List-Id: kug1977 schrieb: > Hi, > > I'm new to Ada, but this is something, I'm interested in. Apple > released GCD as open source (http://www.macnn.com/articles/09/09/11/ > tech.may.encourage.support/) and I asked myself, will the Ada Tasking > benefied from GCD or is this something completely different. > > In GCD a task can be expressed either as a function or as a "block". > "Blocks" are an extension to the syntax of C, C++, and Objective-C > programming languages that encapsulate code and data into a single > object in a way similar to a closure. > > In my understanding of Ada Tasking, the Ada tasks are no more then OS > threads running a code block, if the OS support threads. Uhm, from a use case perspective, Ada task and Apple GCD share some facilities (perhaps not surprisingly, they are both about concurrency.) But there is just a little more, I'd say, on either side, though towards different ends WRT level of abstraction. (And Ada tasks need to be considered together with protected objects.) I guess these are a few differences: Ada tasks allow a form of inter-task communication that is (I think) not directly available in GCD. Ada tasks have - entry queues - select - guards - requeue AFAICS, Apple chose this: "Serial dispatch queues offer a more efficient alternative to locks and other synchronization primitives." Alongside this, GCD requires - event handling blocks (queued, and saturating, IIUC), and - dispatch groups (waiting for the completion of GCD tasks on concurrent GCD queues; former thread join). This latter use of dispatch groups as means to block and wait looks like a handmade rendevouz, doesn't it? Similarly, where Ada offers protected objects, Apple GCD offers serial queues: "Serial queues are often used to synchronize access to a specific resource." The "main dispatch queue" (serial) seems to have a counterpart in Ada's environment task. Also, "because it runs on your application's main thread, the main queue is often used as a key synchronization point for an application." Not sure yet about the producer-consumer example they give for Apple GCD; is this really a poor man's Linda? "When your producer has work to be done, all it has to do is add that work to a queue and let the queue process the item." The semaphores in GCD announce to have an optimization, reaching out for the OS only when needed. If Ada RTSs don't do this already, maybe it is possible they do now. Is it bold to speculate that GCD queues are both: lower level than Ada tasks and protected objects, and, therefore, could offer means to implement Ada tasking?