comp.lang.ada
 help / color / mirror / Atom feed
* Grand Central Dispatch (GCD)
@ 2009-09-15  7:31 kug1977
  2009-09-15 11:18 ` Georg Bauhaus
  0 siblings, 1 reply; 2+ messages in thread
From: kug1977 @ 2009-09-15  7:31 UTC (permalink / raw)


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. The compiler
add system intrinsic code to use the OS' tasking. On the other hand
GCD is a library, so maybe linking against this lib would bring me
this feature; but than in an not Ada like way, I guess.

Thanks
kug1977



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Grand Central Dispatch (GCD)
  2009-09-15  7:31 Grand Central Dispatch (GCD) kug1977
@ 2009-09-15 11:18 ` Georg Bauhaus
  0 siblings, 0 replies; 2+ messages in thread
From: Georg Bauhaus @ 2009-09-15 11:18 UTC (permalink / raw)


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?



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-09-15 11:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-15  7:31 Grand Central Dispatch (GCD) kug1977
2009-09-15 11:18 ` Georg Bauhaus

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