Grand Central Dispatch

Posted:
in macOS edited January 2014
Ok, exactly how is GCD in Snow Leopard going to work if you are using a concurrent programming language to start off. Especially if you are using the Erlang VM (Erlang and Reia)?



Will GCD get in the way?

Will it ignore these languages and let them do there thing but keep track of what they have done so it knows availability of resources?



Just wondering how that is going to work.

Comments

  • Reply 1 of 10
    mdriftmeyermdriftmeyer Posts: 7,501member
    Quote:
    Originally Posted by Dego899 View Post


    Ok, exactly how is GCD in Snow Leopard going to work if you are using a concurrent programming language to start off. Especially if you are using the Erlang VM (Erlang and Reia)?



    Will GCD get in the way?

    Will it ignore these languages and let them do there thing but keep track of what they have done so it knows availability of resources?



    Just wondering how that is going to work.



    http://lists.apple.com/mailman/listinfo
  • Reply 2 of 10
    karl kuehnkarl kuehn Posts: 756member
    GCD requires "blocks", which at this point are C/C++/Obj-C only, but I am sure that this will be extended to other languages at some point (or by someone), but I don't have any idea if blocks are going to map well to Erlang and others. GCD is then a system resource that helps programmers schedule these blocks to be run on system resources in a way that pays attention to the hardware available on the computer at the time.



    So it should have no effect on your current code (other than maybe the jobs scheduled with GCD would compete with yours for system resources... just like any other program). But if you decided to re-write your code in C, this could help you manage the threads as you parallelize (or in some cases as you serialize).
  • Reply 3 of 10
    dego899dego899 Posts: 3member
    Quote:
    Originally Posted by Karl Kuehn View Post


    GCD requires "blocks, which at this point are C/C++/Obj-C only, but I am sure that this will be extended to other languages at some point (or by someone), but I don't have any idea if blocks are going to map well to Erlang and others. GCD is then a system resource that helps programmers schedule these blocks to be run on system resources in a way that pays attention to the hardware available on the computer at the time.



    So it should have no effect on your current code (other than maybe the jobs scheduled with GCD would compete with yours for system resources... just like any other program). But if you decided to re-write your code in C, this could help you manage the threads as you parallelize (or in some cases as you serialize).



    No this is good, What I was looking for, so standard C, C++, Obj-C and I am guessing any scripting language made from one or of these three will be handled by GCD. All other Function or Concurrent programming languages Scala and Clojure (for the JVM) and Erlang and Riea (for the Erlang VM) do there own things instead of going through GCD. But I am I write in guessing there is away for the GCD to see the usage of resources by non-GCD programs so that it does not to step on the non-GCD languages? And Visa Versa?
  • Reply 4 of 10
    karl kuehnkarl kuehn Posts: 756member
    Unfortunately I don't think that other systems will be able to know about the resources in use by GCD (based programs), and vise-versa. This is one of the problems that GCD was designed to overcome. Some of the problem is already solved by the scheduler (for the CPU resources this is by thread), but GCD allows for the OS to make better informed decisions about this.



    And my guess is that scripting languages will take a long time to include GCD, if they ever do. The reason is that GCD is only on MacOS X. And while it might be the biggest of the *nix variants, it is not the dominent one for any of those communities. And working GCD into the language would likely require some big changes, and doing that for MacOS X only is going to be a hard sell in those communities.
  • Reply 5 of 10
    amoryaamorya Posts: 1,103member
    Essentially, GCD is a library of C functions that handle creating and using multiple threads for you. You (the programmer) pass in some code to be run, and the system runs it in an appropriate place.



    It's not some all-encompassing miracle that will affect everything. To use it, you have to be writing in C/C++/ObjC, and you have to actually call the GCD functions. They're pretty easy to use but not automatic.



    If you don't use GCD, it won't change anything. Your code will run exactly as it did before.



    Amorya
  • Reply 6 of 10
    dego899dego899 Posts: 3member
    Quote:
    Originally Posted by Amorya View Post


    Essentially, GCD is a library of C functions that handle creating and using multiple threads for you. You (the programmer) pass in some code to be run, and the system runs it in an appropriate place.



    It's not some all-encompassing miracle that will affect everything. To use it, you have to be writing in C/C++/ObjC, and you have to actually call the GCD functions. They're pretty easy to use but not automatic.



    If you don't use GCD, it won't change anything. Your code will run exactly as it did before.



    Amorya







    Ok . . . now I get it I thought GCD was part of the Snow Leopard OS that was doing these things for you. Thats why I got confused how GCD would handle Functional / Concurrent languages since they already do it. Ok C Libraries that makes more sense.
  • Reply 7 of 10
    mdriftmeyermdriftmeyer Posts: 7,501member
    Quote:
    Originally Posted by Dego899 View Post


    Ok . . . now I get it I thought GCD was part of the Snow Leopard OS that was doing these things for you. Thats why I got confused how GCD would handle Functional / Concurrent languages since they already do it. Ok C Libraries that makes more sense.



    Visit the LLVM Project.



    http://llvm.org



    Read up on the mailing lists and more.
  • Reply 8 of 10
    karl kuehnkarl kuehn Posts: 756member
    Quote:
    Originally Posted by mdriftmeyer View Post


    Visit the LLVM Project.



    http://llvm.org



    Read up on the mailing lists and more.



    LLVM is not required to use GCD as far as I know. They certainly had to add blocks support to LLVM, but that is only one part of what makes GCD tick. The other part is the OS service that schedules the blocks to be run (taking care of many of the difficult parts of multithreading, and certainly simplifying the job of figuring out the optimal multithreading setting for the hardware in use).



    Note that this is not just a C library, it also requires an extension of C, and a OS service.
  • Reply 9 of 10
    cej38cej38 Posts: 2member
    My hope is that the JVM that Apple ships with Snow Leopard will be able to assign threads to processors through GCD. Then, any program written to the JVM, that uses concurrency, could use the extra power that comes with GCD.



    In fact, if Apple doesn't do this, I think they are possibly losing out on being able to sell computers to the growing number of people that are using languages like Erlang and clojure. I have several buddies that are into these languages, and their linux boxes, but if someone came out with an operating system that had a JVM that could use the resources of a GPU as well as the CPU they would switch pretty quickly (even if it came from Redmond, WA).
  • Reply 10 of 10
    shadowshadow Posts: 373member
    Apple has hard time improving it's own OS and a bunch of applications. GCD is one of the technologies that paves the road to the future but there is a huge amount of work that needs to be done, both to optimize it further and to optimize all parts of the OS and all Apple applications to take full advantage of it. Ah, and there is the work on the iPhone OS and a handful of iPhone apps...



    Apple has zero resources and zero interest to optimize third party products and to push developers away from their development environment.
Sign In or Register to comment.