Slashdot Mirror


Apple's Grand Central Dispatch Ported To FreeBSD

bonch writes "Apple's Grand Central Dispatch, which was recently open sourced, has been ported to FreeBSD and is planned to be included by default in FreeBSD 8.1. Also known as libdispatch, the API allows the use of function-based callbacks but will also support blocks if built using FreeBSD's clang compiler package. There's already discussion of modifying BSD's system tools to use the new technology." The port was originally unveiled last month at the 2009 Developer Summit in Cambridge. Slides from that presentation are available via the Dev Summit wiki.

205 comments

  1. Bad Apple by 93+Escort+Wagon · · Score: 5, Funny

    Always taking from the open source community, and never giving back!

    --
    #DeleteChrome
    1. Re:Bad Apple by Anonymous Coward · · Score: 0

      STFU...there's a reason they ported BSD rather than Linux...

    2. Re:Bad Apple by Anonymous Coward · · Score: 0

      Thanks for yesterday's trash.

    3. Re:Bad Apple by Anonymous Coward · · Score: 0

      Little touchy there, aren't we Mr. Shuttleworth?

  2. No. Really? by Anonymous Coward · · Score: 0, Funny

    Oh yes. Fanbois are already out?! They do it once, and Lo and Behold!!! THEY ALWAYS DO IT!!!

    1. Re:No. Really? by beelsebob · · Score: 5, Informative

      Yep, apple didn't give back all their code on WebKit, or all of Darwin, or all of launchd, or all their patches on zfs, or their code on MacPorts, or darwin streaming server, or CalDav, or iCal format, or their Calander server, or their code on their X server, or their code on ruby, or a bunch of code on smart card services...

      Wait, yes they did.

    2. Re:No. Really? by cinderblock · · Score: 1, Redundant

      You obviously know sarcasm when you see it... :-P

    3. Re:No. Really? by phantomcircuit · · Score: 1

      all their patches on zfs

      Did they really have a choice there?

    4. Re:No. Really? by MMC+Monster · · Score: 1

      They could have chosen not to ship with zfs support.

      Given how little OS X supports zfs, they could have left it out without any big deal.

      --
      Help! I'm a slashdot refugee.
    5. Re:No. Really? by phantomcircuit · · Score: 1, Interesting

      So any modifications to ZFS that they included in their shipped product had to be distributed? GEEE THANKS FOR THAT APPLE and isnt webkit based on khtml?

    6. Re:No. Really? by zach_the_lizard · · Score: 3, Informative

      Yes, WebKit is based on KHTML; Apple forked it, IIRC.

      --
      SSC
    7. Re:No. Really? by phantomcircuit · · Score: 0, Troll

      So we're supposed to be thankful for them following the terms of the license? yeah... that makes sense

    8. Re:No. Really? by DurendalMac · · Score: 4, Insightful

      Several things didn't need to be open sourced, such as WebObjects and GCD. Quit your crying. FOSS zealots love to whine about Apple only doing what's required, but they fail to realize that it's a symbiotic relationship. Apple can use existing code to fit their needs, and in return, the open source community gets all of the improvements made by professional coders. It's a win/win, but the mini-Stallmans will never see it that way.

    9. Re:No. Really? by postbigbang · · Score: 0, Troll

      Good grief: "professional coders"?????

      Where do you think they got the code from in the FIRST PLACE????

      And citing Stallman isn't a God-Win in a FOSS argument. Get real.

      --
      ---- Teach Peace. It's Cheaper Than War.
    10. Re:No. Really? by Anubis350 · · Score: 1

      Your post can quite literally be summarized as:

      "this stuff that they improved, they didnt invent it so improving it doesnt count!"

      also known as:

      "I'm dont understand open source"

      --
      "goodbye and hello, as always" ~Prince Corwin, from Zelazny's Amber series
    11. Re:No. Really? by phantomcircuit · · Score: 1

      Actually what I'm saying is that just because they play by the rules doesn't make them special.

      They use the best software available to them for the job they want to complete. If that happens to be an open source product then they are going to use the open source project. If they use an open source project they are going to want to fix and improve it. With open sources fixes and improvements must be contributed back to the community. They do not deserve any special acknowledgement because they are doing things in their best interest that also happen to follow the rules.

      When is the last time that Apple released an entirely new project? For example Sun released ZFS under the CDDL.

    12. Re:No. Really? by Jerry+Smith · · Score: 3, Insightful

      When is the last time that Apple released an entirely new project? For example Sun released ZFS under the CDDL.

      Why reinvent the wheel? They adopt it, improve it and release the improvements. At least they add. They deliver. When is the last time Stallman released an entirely new project? Or finished one? "Although nearly all components have been completed long ago and have been in production use for a decade or more, its official kernel, GNU Hurd, is incomplete and not all GNU components work with it." from the reliable-as-ever Wikipedia. Apple is not Stallman. They do not serve the same market. Apple is in hardware/software/platform, Stallman is in philosophy. Fair enough, einen Unterschied muß es geben.

      --
      All those moments will be lost in time, like tears in rain. Time to die.
    13. Re:No. Really? by gutter · · Score: 3, Insightful

      Well, we have the subject of this article, Grand Central Dispatch. We also have Darwin & XNU, their version of the Mach kernel. There is also Bonjour, their version of zeroconf, and their streaming server (Quicktime Streaming Server). They also purchased the source to gimp-print (now called Gutenprint) so they no longer have any obligation to keep it open source, but they do, and they keep releasing the source. How much more do you need?

      --
      Check out DRM-free movies at http://www.bside.com
    14. Re:No. Really? by Jerry+Smith · · Score: 1

      Well, we have the subject of this article, Grand Central Dispatch. We also have Darwin & XNU, their version of the Mach kernel. There is also Bonjour, their version of zeroconf, and their streaming server (Quicktime Streaming Server). They also purchased the source to gimp-print (now called Gutenprint) so they no longer have any obligation to keep it open source, but they do, and they keep releasing the source. How much more do you need?

      I agree, they could go closed/proprietary like Opera, yet they choose to keep things open and improve on them. They're in it for the money, like a lot of companies, and if that means cooperating with OpenSource Software, so be it. It's a bit of a win/win situation. It's just that their business-model does not allow to go fully free and open, bit of a shame, but oh well, one can't have ones cake and eat it.

      Disclaimer: former Apple employee, now in education and liking all things open and free, but still without losing touch with reality.

      --
      All those moments will be lost in time, like tears in rain. Time to die.
    15. Re:No. Really? by Anonymous Coward · · Score: 0

      you forgot CUPS lol

    16. Re:No. Really? by Anonymous Coward · · Score: 3, Funny

      But apart from CUPS, LLVM/clang, Webkit, Darwin, launchd, patches for zfs, MacPorts, darwin streaming server, CalDav, iCal, the Calendar server, code for Ruby, code for X server and GCD, what has Apple ever done for us?

    17. Re:No. Really? by RichiH · · Score: 2, Informative

      Webkit is kinda special. For ages, Apple did nothing other than releasing the full source every time they released binaries.

      They did _not_ release anything under SCM control, which meant tracking patches etc was _literally_ impossible for the KDE team. No matter what the KDE team did or how often they asked, this did not change. This is a large part of why KHTML and Webkit are as different as they are now. Using both KHTML and the Webkit Kpart in KDE 4.3.2, I can tell you that there are a lot of little differences in rendering and, that is where it hurts, usability. Sucks.

      So while Apple followed the letter of the license, they went against its spirit in every possible way for a long time. This may have changed somewhat (iPod, iTunes...?), but one should be aware of the history.

    18. Re:No. Really? by RichiH · · Score: 1

      The FLOSS community gives all their mailing lists, internal processes, every single commit along with the commit message to Apple.

      Apple (this has improved) gave the FLOSS community one huge source tarball without any context with every OS X release.

      Those bad, bad FLOSS zealots, look at all the win/win they received!

    19. Re:No. Really? by mi · · Score: 2, Funny

      Where do you think they got the code from in the FIRST PLACE????

      From the professional coders at AT&T?

      (ducks...)

      --
      In Soviet Washington the swamp drains you.
    20. Re:No. Really? by jo_ham · · Score: 1

      "All" including the in-house closed-source stuff they paid a huge bunch of coders to write, or do you think that literally everything Apple turns out is just "polished" OSS material with a fancy GUI on it?

      I think the GP's context is that "professional" in this term means "coders who do it for a living" rather than just as a hobby, or a professional who contributes to OSS in their spare time. I know it's clearly not that simple, but I don;t think the inference is that OSS coders are not professionals, just that they don't get to spend as much time on non-commercial projects in most cases (excepting things like Firefox, or something like Open Office or other 'keynote' large, supported projects).

      Apple have released a lot more to the FOSS community than they were "forced to" by the licences - in that respect they are similar to other big fishes like IBM and even Microsoft (shock horror).

      So sure, Apple haters will jump on "Webkit came from KHTML, they *have* to release changes!" (read: they wouldn't if they could find any legal way around it) and ignore things that they did write in house and open source with no prodding. libdispatch just happens to be one of those things.

    21. Re:No. Really? by jo_ham · · Score: 1

      I seem to remember something about loggerheads from both Apple and the KHTML team on those source code releases. Like two tigers in a room trying to decide how to cook a goat.

    22. Re:No. Really? by xouumalperxe · · Score: 1

      When is the last time that Apple released an entirely new project?

      The "last time" would be the very subject of this article.

    23. Re:No. Really? by Goaway · · Score: 1

      (this has improved)

      Yes, let's leave this in parenthesis and pretend it never happened, pretend they never turned KHTML into one of the most successful open source projects, across many platforms, and endlessly complain about something that happened for a few months while Apple was setting up their real project.

    24. Re:No. Really? by beelsebob · · Score: 1

      In actual fact, they *did* chose not to ship with zfs support, and still provide their source.

    25. Re:No. Really? by beelsebob · · Score: 2

      Uh, yes? Sure, you *made* them give up their source if they used your project, but that doesn't change the fact that they *did* use your project, and then contribute back hundreds of thousands of improvements. Or are you suggesting that khtml without apple's assistance would be in the position WebKit is now?

    26. Re:No. Really? by beelsebob · · Score: 1

      Actually what I'm saying is that just because they play by the rules doesn't make them special.
      That's kinda the point I'm making. FOSS zealots single out apple as *being* special. They tend to regard them as a special kind of evil, while in reality, they're both contributing back to the projects they are involved in, *and* starting more projects of their own (see libdispatch, clang, etc).

    27. Re:No. Really? by beelsebob · · Score: 2, Insightful

      In the mean time... When is the last time that Apple released an entirely new project?
      You do realise this article is *about* apple releasing the source code to libdispatch?

    28. Re:No. Really? by beelsebob · · Score: 1

      You do realise that Konquerer is moving to WebKit, from apple's svn repository? How do you think google contribute code to WebKit? Through the magical monolithic-patch portal?

    29. Re:No. Really? by Anubis350 · · Score: 1

      You know, part of the problem with the FOSS world sometimes is the fixation on "new, shiny, awesome". Sometimes it's more important to do that last 1% that turns a great idea, and cool neat project into something production quality.

      Refinement, improvement, and stability fixes are all things that are the least sexy for FOSS devs to donate their time towards, and some of the most useful things for their users. A lot of that work is done by people being *paid* to work on that software, like, say, by Apple!

      Is apple the only one? Of course not! When Sun releases something impressive, or IBM, or Intel, or.. etc we have a sotry about that on /. too. This story, however, happens to be about Apple (and, amusingly, them releasing the source to something *new*).

      --
      "goodbye and hello, as always" ~Prince Corwin, from Zelazny's Amber series
    30. Re:No. Really? by Anonymous Coward · · Score: 0

      GCD is hardly important; any programmer should be able to write a greatest common divisor function.

    31. Re:No. Really? by RichiH · · Score: 1

      While it's true that some signs point to KDE migrating to WebKit at some point,

      a) KHTML will _not_ be removed before KDE 5
      b) WebKit has still a long way to go. I just submitted half a dozen bugs to Qt.
      c) KDE will move to WebKit from Qt, not Apple

      Not sure how your Google comment relates to anything I said, though. Unless you missed me talking to the past tense in the earlier post ;)

    32. Re:No. Really? by RichiH · · Score: 1

      a) How am I pretending it has never improved? I even say so in what you quoted :)
      b) KHTML was very successful and widely in use before WebKit forked off
      c) Endlessly? Others would say I am pointing something relevant and new out in a discussion about a particular topic, but hey..
      d) A few months? While poor Apple was setting up stuff? Reread what I said about several releases.

      Do I get a prize for being trolled by an Apple fanboy, now? I think this was my first time..

    33. Re:No. Really? by DurendalMac · · Score: 1

      Because professional coders are the only people who contribute to open source, right?

    34. Re:No. Really? by DurendalMac · · Score: 1

      Um, KHTML was not in wide use, at least nowhere even remotely close to Webkit today. Konqueror had diddly squat for marketshare.

    35. Re:No. Really? by beelsebob · · Score: 1

      Where do you think WebKit from Qt comes from? Oh yes... Apple's svn servers >.

      Google relates to this because they too are working on web kit's svn in writing chrome.

    36. Re:No. Really? by RichiH · · Score: 1

      Several projects used it, but yes WebKit made usage explode. Still, KHTML has been successful before WebKit, as well.

    37. Re:No. Really? by RichiH · · Score: 1

      Where do you think WebKit from Apple comes from? Oh yes... KDE's svn servers >.

      The point is that while Apple, Qt, Google etc will certainly work together, the code level I care about and with which I am familiar with when it comes to community, reporting, etc is Qt, not Apple. Apple may or may not merge back what Qt does to fix WebKit from KDE's pov, but as Apple has been known to make strange usability decisions, I'd rather not bet onto it.

      As an aside, no one would have stopped Apple from contributing to KHTML. Instead, they decided to fork the codebase before doing anything else. Maybe understandably so from a business level, but certainly not so much from a code level.

      Which is, by the way, the reason why I don't care for Apple's WebKit, either: They did not extend the same courtesy to "us".

    38. Re:No. Really? by beelsebob · · Score: 1

      Where do you think WebKit from Apple comes from? Oh yes... KDE's svn servers >.
      No, they don't, webkit's svn repository is at http://svn.webkit.org/repository/webkit/trunk.

      Now go whois that domain, and tell me who owns it?

      The point is that while Apple, Qt, Google etc will certainly work together, the code level I care about and with which I am familiar with when it comes to community, reporting, etc is Qt, not Apple. Apple may or may not merge back what Qt does to fix WebKit from KDE's pov, but as Apple has been known to make strange usability decisions, I'd rather not bet onto it.
      No, the point is, you're trying to slag off apple saying that they don't give back the source code in any usable form, and yet, there, sat right in front of you is apple's svn server containing the authoritative source for WebKit.

      At a guess, you'll be complaining that their bug database isn't open yet... which... yep, you guessed it, it *is*.
      https://bugs.webkit.org/query.cgi?format=specific&product=WebKit

      People keep spreading FUD about how much of a bad citizen apple is being with WebKit, and yet, there are at least two companies (nokia and google) and a large open source project (Qt) interacting with them quite happily.

    39. Re:No. Really? by RichiH · · Score: 1

      What I meant is "where did it come from originally". The point you are missing is that while Qt syncs WebKit from upstream on a more or less regular basis, but they keep the right to have their own local modifications. Just as WebKit did with KHTML.

      > No, the point is, you're trying to slag off apple saying that they don't give back the source code in any usable form, and yet, there, sat right in front of you is apple's svn server containing the authoritative source for WebKit.

      No, I am saying that for years, they went fuck all and did _not give a damn about anyone except themselves_. There was no public SVN. All there was were monolithic tarballs every time OS X was released in a new version.
      Things may have changed, and in fact, they have. But there is no reason to forget the past. Apple is not the bunch of nice altruists you want to make them appear as.
      They play hard ball when they think it benefits them (iTunes, iPhone, iPod, WebKit in former times) and play nice when they think it benefits them (WebKit today, Grand Central).

      It is their privilege do so as they are a distinct entity on the marketplace with internal decision processes. This may not be the best for the community or humanity at large, but it is their privilege to do so.

      Same as it is the privilege of the community at large to remember this fact and base future decisions on the past behaviour of other entities, be they Apple, MS or Oracle.

      > People keep spreading FUD about how much of a bad citizen apple is being with WebKit, and yet, there are at least two companies (nokia and google) and a large open source project (Qt) interacting with them quite happily.

      Au contraire. I refuse to to stop spreading factual and easily proven facts about Apple's _past behaviour_ when people seem to forget what history WebKit has. Counting Nokia and Qt separately does not make sense, btw ;)

      In any case, this will be my last post regarding this topic as we clearly will not be able to agree on anything.

    40. Re:No. Really? by Gilmoure · · Score: 1

      The roads?

      --
      I drank what? -- Socrates
    41. Re:No. Really? by Gilmoure · · Score: 1

      Tigers don't cook goats. They pretty much eat them as they catch them.

      --
      I drank what? -- Socrates
  3. They should use clang instead of GCC by Anonymous Coward · · Score: 0, Flamebait

    I noticed in their last slide they asked how to put closures into GCC. Why bother? Just use the Apple LLVM clang front end where it is already implemented and ditch GCC altogether.

    1. Re:They should use clang instead of GCC by larry+bagina · · Score: 4, Informative

      Apple maintains their own gcc fork which supports blocks/closures.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    2. Re:They should use clang instead of GCC by brass1 · · Score: 1

      Apple maintains their own gcc fork which supports blocks/closures.

      The probability that Apple migrates away from gcc is approaching 1 at great speed.

    3. Re:They should use clang instead of GCC by bconway · · Score: 1

      And their fork is publicly available under the BSD license and in SVN for all to enjoy.

      --
      Interested in open source engine management for your Subaru?
    4. Re:They should use clang instead of GCC by bill_mcgonigle · · Score: 2, Interesting

      Apple maintains their own gcc fork which supports blocks/closures.

      why won't gcc take the patches?

      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    5. Re:They should use clang instead of GCC by Anonymous Coward · · Score: 2, Informative

      Because Apple is sticking with GPLv2

    6. Re:They should use clang instead of GCC by Anonymous Coward · · Score: 0

      Umm, wait, what? Their fork of a GPLed project is licensed under BSD?

      My understanding of law didn't allow that; maybe I'm wrong?

    7. Re:They should use clang instead of GCC by jcr · · Score: 3, Interesting

      The probability that Apple migrates away from gcc is approaching 1 at great speed.

      That writing's been on the wall for quite a long time now. GCC has been a severe limitation on what they could do with Xcode for far too long. With LLVM, I'm expecting shortly to get away from the edit/compile/debug cycle and have a pause/edit/resume cycle instead.

      Right now in Quartz Composer, you can write GL SLANG shaders that are compiled on the fly as you type. It's amazing to see the effects of changes immediately.

      -jcr

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
    8. Re:They should use clang instead of GCC by cortana · · Score: 1

      Has anyone asked them?

    9. Re:They should use clang instead of GCC by TheRaven64 · · Score: 4, Informative

      A massive case of NIH from the GCC team with regard to Apple. See also the patches that Apple submitted well over a year ago adding declared property support to GNU gcc. I found it easier to write all of the code required for clang to support the GNU Objective-C runtime than make even small changes to Objective-C support in GCC (in spite of not having used C++ for a few years and really hating the language).

      Oh, and I've had blocks working with clang on FreeBSD for quite a while (since several months before Apple publicly released an OS supporting them, in fact). I added the required runtime library support into Etoile's ObjectiveC2 framework a while ago, which also provides the run time support for most of the Objective-C 2 features. This framework is going to go away soon, because I'm now maintaining a fork of the GNU Objective-C runtime in the GNUstep repository, which merges these improvements and also incorporates most of the ideas from my experimental Objective-C runtime library (without breaking backwards compatibility, although you don't get all of the features if you don't use the new ABI).

      By the way, porting to *BSD is much easier than porting to Linux. Libdispatch is based around the kqueue mechanism for unifying kernel event sources, and there is currently no in-tree equivalent for Linux. There are four out-of-tree sets of patches providing equivalent functionality (that I know of, there may be more), as is common with Linux development. On Solaris you can do the same thing with completion ports, which are roughly semantically equivalent but have a different interface.

      --
      I am TheRaven on Soylent News
    10. Re:They should use clang instead of GCC by Shinobi · · Score: 2, Interesting

      It goes further and deeper(and uglier) than that. Remember when Apple released the G5's? Apple actually submitted patches to GCC, but they were declined, with GCC's official stance being "It would reduce GCC's portability". However, a few weeks later, IBM submitted some patches for GCC, that were summarily accepted. IBM's patch package contained many of Apple's patches for GCC.

    11. Re:They should use clang instead of GCC by bill_mcgonigle · · Score: 1

      Thank you for the great response. May the meritocracy work this out.

      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
  4. Multicore Enhancements!! :) by jpedlow · · Score: 5, Interesting

    My first question was "So...what does this do?" Apparently it is a more efficient way of scheduling threads on multi-core systems http://images.apple.com/macosx/technology/docs/GrandCentral_TB_brief_20090903.pdf apple's site says this: "Grand Central Dispatch (GCD) in Mac OS X Snow Leopard addresses this pressing need. It’s a set of first-of-their-kind technologies that makes it much easier for developers to squeeze every last drop of power from multicore systems. With GCD, threads are handled by the operating system, not by individual applications. GCD-enabled programs can automatically distribute their work across all available cores, resulting in the best possible performance whether they’re running on a dual-core Mac mini, an 8-core Mac Pro, or anything in between. Once developers start using GCD for their applications, you’ll start noticing significant improvements in performance. " So this seems good then.

    1. Re:Multicore Enhancements!! :) by turgid · · Score: 1, Interesting

      That sounds like marketing-speak. That's the whole point of preemptively scheduled native threads.

      GCD-enabled programs can automatically distribute their work across all available cores

      Been there, done that on Solaris and Linux 10 years ago in plain old C. No magic required, just

      #include <pthread.h>

      and away you go. In fact, I spent an hour one day writing some C to automatically multi-thread those embarrassingly parallel array operations.

      man 3 pthread_create - the world is your lobster.

    2. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 2, Informative

      Ah, but the benefit of Grand Central is that you don't need to worry (as much) about thread synchronisation and message passing. Just give it the blocks of code that are independent of each other, collect the results, and you're done. Think of it as giving you a ready-made scaffold; sometimes, it's more efficient to build your own that matches your needs more closely, but usually, it's just simpler to use what's already there.

      In other words, the whole point of Grand Central is that you don't need to worry as much about the "boilerplate" code around threads, and can focus more on what the code actually needs to do. This is a Good Thing. If it doesn't fit your needs, nobody is forcing you to use it ... but if it does, it makes life a hell of a lot easier.

    3. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 0

      Did you also check how many cores the system had to determine the optimum number of threads? Did you factor in other system activity? Can you easily handle dependencies on things that aren't embarrassingly parallel?

    4. Re:Multicore Enhancements!! :) by zn0k · · Score: 4, Informative

      While you certainly don't deserve a "Troll" rating, the real improvement GDC brings over current implementations of concurrency is that one central authority is aware of all GDC enabled applications, and can therefore make decisions with knowledge of the entire system load and its capabilities when spinning of threads. When you spin of threads independently in each app you have to guess what the rest of the system looks like. You also have to either guess, investigate or have the user configure the general capabilities of the system.

    5. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 0

      There are plenty of articles about it online. It's more than what you say, and also less (i.e., at first glance it's a thread pool with queued tasks). Firstly, how do you scale your solution transparently? How do you make it cooperate with other software that's running, to get most efficient use of your resources? GCD does that, and blocks makes it simple, and adding multithreading to your application is a matter of adding a couple of lines of code (see the code examples in some of the articles), not managing entire pthreads stuff or changing entire swathes of code. It makes threading trivial, for the programmer, once the programmer has identified where to multithread.

    6. Re:Multicore Enhancements!! :) by moosesocks · · Score: 5, Informative

      Ars Technica has a great overview of what GCD is, and why it's important.

      I haven't done much multithreaded programming in C, although this looks like an absolute godsend to those who do. Maybe someday we can actually have a modern desktop as responsive as BeOS was...

      The article also contains a bit of information about Apple's compiler strategy and refinements to the C language itself. Most of these have been open-sourced under a permissive license, which is pretty damn cool.

      --
      -- If you try to fail and succeed, which have you done? - Uli's moose
    7. Re:Multicore Enhancements!! :) by wootest · · Score: 5, Insightful

      GCD is far more encompassing than just spawning threads. It's mainly a library for task-based parallelization (my wording, not theirs) and has some other goodies in it as well.

      For starters, unless it's not apparent by now, just spawning a new thread to run every such job is too heavy. Scheduling a new GCD job (and all of them will get run on one of a bunch of thread pool threads) is on the range of tens of CPU instructions; on Mac OS X, where GCD originated, spawning a new thread steals away in the vicinity of one megabyte (I can't seem to find an exact number) just for various bookkeeping. That's a lot of setup; even if there's a lot of fat to cut there, the best solution is probably not to spawn a new thread every time.

      The API is also very neatly designed. Tasks can be created and added to groups or queues and run synchronously or asynchronously. Semaphores, queues and event sources (which will trigger the addition of an event handler to a queue automatically) can all be paused and resumed to more easily control the flow. Neat, especially combined with the creation of queues that you set up to just funnel work onto another queue.

      Add to that the existence of several global queues with varying priorities (corresponding to a set of worker threads at each priority) and the potential for smarts for a system that can see the entire picture with regards to load within the program and across the system. I don't know the extent to which such smarts exist already, but I think you'll agree that with more metadata available, such a scheduler would be better equipped than one fiddling with coarser-grained threads.

      So yeah, this is nothing like "just" spawning threads. (I've never worked directly with pthread; it may very well reuse threads, but it didn't look like it from the man page you referred to.) None of it, as far as I can tell, is Apple inventing something new and breakthrough, but it's still a damn good API with a good consolidated set of computationally cheap features whose level of abstraction solves problems.

    8. Re:Multicore Enhancements!! :) by Stratoukos · · Score: 5, Insightful

      Maybe someday we can actually have a modern desktop as responsive as BeOS was...

      BeOS was indeed very responsive, but it was also notoriously difficult to program for. Apple seems to have done a great job at creating a powerful framework, while keeping it easy enough to be actually used by the developers.

      --
      It may be 7 digits, but at least it's a semiprime
    9. Re:Multicore Enhancements!! :) by Just+Some+Guy · · Score: 5, Insightful

      Been there, done that on Solaris and Linux 10 years ago in plain old C. No magic required, just

      #include <pthread.h>

      and away you go.

      Piece of cake! Of course, you have no idea how many other processes are tossing threads at their workload and so have no idea if this is a great time to spawn another 8 to really load out the CPU or whether you should just spawn 2 and let some other processes have their time. That's what GCD buys you.

      --
      Dewey, what part of this looks like authorities should be involved?
    10. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 0

      Not true. Go read the spec again. libdispatch manages thread pools. It is on a per-app basis. It does not take into how multi-threaded the other applications on the system are. All it is is a way of automagically managing the per-app thread pool & cheaply assigning tasks to existing threads.

      Very cool syntax, but it does not load balance the system (that's what the kernel is for).

    11. Re:Multicore Enhancements!! :) by zn0k · · Score: 1

      It takes into account every other libdispatch enabled app. As per the spec.

    12. Re:Multicore Enhancements!! :) by Space+cowboy · · Score: 2, Informative

      Parent spouts bollocks. Simon.

      --
      Physicists get Hadrons!
    13. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 4, Informative

      In your zeal to take one statement out of context, you missed the point of the framework. Using dispatch queues, I don't have to create threads, an expensive operation, and I don't have to agonize over performance profiles to determine the right number of threads to use. The operating system automatically maintains a global pool of worker threads based on available system resources, and you submit an asynchronous block of code which the system will assign to a thread and run for you based on current system state--that's what the "automatically distribute their work across all available cores" part means. Quite different from merely creating a pthread. Your code will run in an optimal number of threads for the system it's on, whether it's a Mac Mini Core Solo or an eight-core Mac Pro.

      You can even distribute the iterations of a for-loop across queues using dispatch_apply(). Imagine doing a lot of expensive work on items in a collection, automatically threaded for the cores of the system it's running on. Here's an intro to Grand Central Dispatch. The followup articles on the site are also recommended.

      The API to submit a block for asynchronous execution is very simple:

      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
              do_something_computationally_expensive();
      });

      Posting anonymously since my "bonch" account has been modbombed.

    14. Re:Multicore Enhancements!! :) by ceoyoyo · · Score: 1

      Gee, I've used pthreads quite a bit and I didn't ever notice the nicely organized thread queue infrastructure. Or anything else in GCD, actually. And I sure don't remember parallelizing a FOR loop with one or two lines of code with it.

      GCD is NOT a thread library.

    15. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 0

      pthread_create() doesn't necessarily mean that a kernel thread was created. It's an application level concept.

      http://en.wikipedia.org/wiki/Thread_%28computer_science%29#Models

      The operating could choose to create a new kernel entity or not. Since the kernel knows everything that's going on, it could reduce the number of KSEs if the load is too high.

      http://www.freebsd.org/kse/index.html

    16. Re:Multicore Enhancements!! :) by buchner.johannes · · Score: 2, Insightful

      So does Linux need that, do they think about implementing something similar, porting it or what is happening?

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    17. Re:Multicore Enhancements!! :) by liquidsin · · Score: 1

      *slow clap*

      --
      do not read this line twice.
    18. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 1, Informative

      Other posters have provided good answers, however they also miss some important aspects of GCD and repeat less interesting marketing points.

      From my experience the main features of GCD are:

      - It removes the need to determine how many threads should be used to execute parallel sub-tasks.
          One just specifies the tasks and let the system (user-level runtime + kernel) determine how many threads should be dedicated to this work.

          Many comments across the web note that this is useful across processes. In my mind the major benefit is to enable composition of parallel subdivision. In Pthread one would typically say "I have N cores, let's split this task up to to C*N threads (with C close to 1)". That's workable if you do so at high-level of the application logic, but it leads to an explosion in thread count when done in libraries. Your code may be called by M threads in parallel and, unless very careful, you can end-up creation M*C*N threads. Repeats across a few layers and you easily overwhelm the system.

          With GCD you specify the work items, the serialization constraints by pushing to serial or parallel queues. The system decides how to service how to allocate threads to processes and queues.

      - It brings run loops to Posix-level programming
          Developing around run loops is a different programming style which is mostly familiar in UI code. GCD extends this style to low-level code. This is a very powerful programming style which, when used properly, brings similar benefits to control flow that object-oriented programming brings to data management.

      - It unifies Posix-level event handling
          No more sigwait / signal handler / select / poll / waitpid / blocking read() / usleep() for various event sources.
          One just create dispatch sources, points them to a queue unto which to execute handlers, and voila.

          GCD is not the only attempt at unification. Kqueues / epoll+signal fd + timer fd / etc. are similar/earlier attempts, and indeed GCD is built on top of kqueues on Mac OS X. What's significant with GCD is that the APIs are simple enough that they remove a lot of the traps of those other APIs. GCD also takes care of the dispatching logic which is one of the tricky aspect of dealing with those APIs.

    19. Re:Multicore Enhancements!! :) by shutdown+-p+now · · Score: 1

      So far as I can tell, from a .NET guy perspective, GCD is for OS X what Task Parallel Library is for .NET. Or Parallel Patterns Library for VC++ - Microsoft implemented C++0x lambdas in VC++10 mainly for that, in fact, just as Apple added blocks to their gcc fork mainly for GCD. Even the terms mostly match - futures, tasks, task groups.

      Which is good, I guess, since it means that skills obtained with one would be easily transferable to another.

    20. Re:Multicore Enhancements!! :) by shutdown+-p+now · · Score: 1

      So does Linux need that

      It does, but they may not realize that at this point. That's okay - historically, there have been quite a few things which were dismissed with a hand wave for a long time, until suddenly it's the next big thing in Linux land. I recall how that happened for Unicode support, for example.

      On the other hand, this means that FreeBSD gets to be the testing ground, and the inevitable eventual Linux port will be more mature and better polished.

    21. Re:Multicore Enhancements!! :) by wootest · · Score: 1

      I'm a .NET guy too and I've used PFX in production. I think both PFX and GCD are brilliant and are mostly on par when it comes to functionality, but I think GCD may actually be the neater looking API. I'm sure I could have done some of the things I did with GCD's queues in PFX all this time, but I would have never actually thought of it because it'd require separate task managers and task factories and so on. It took me ten minutes to remove almost all locks from a small Cocoa app I had (serialized access to a database) and the idea didn't even occur to me in several similar .NET apps with PFX close at hand.

    22. Re:Multicore Enhancements!! :) by weicco · · Score: 1

      I'm a .NET guy also. This sound similar as ThreadPool.QueueUserWorkItem and couple of delegates. Or am I horribly mistaken?

      --
      You don't know what you don't know.
    23. Re:Multicore Enhancements!! :) by shutdown+-p+now · · Score: 1

      Of course there are still thread pools at the bottom of it, but task is not just a thread. It's a unit of work on a thread that may optionally yield a result (i.e. it can be a future). It can have its status polled, it can be canceled, it can be chained with other tasks to form a pipeline, and you can wait on one or all tasks in a set. And all this doesn't require any explicit locking.

      Also, presumably, task scheduler is somewhat smarter than thread pool when dealing with logically grouped tasks (since it knows which depend on which).

    24. Re:Multicore Enhancements!! :) by qbast · · Score: 1

      And I sure don't remember parallelizing a FOR loop with one or two lines of code with it.

      GCD is NOT a thread library.

      Look at OpenMP then - already included in GCC.

    25. Re:Multicore Enhancements!! :) by IamTheRealMike · · Score: 1

      No, Linux does not need that, nor does MacOS X (I'd hope).

      Look. GCD is classic Apple - a cleverly hyped yet pedestrian technology. It's a thread pool. There's also some odd extension to C to allow for closures, but Java has been doing that since 1995. Anyway. The gimmick is, this thread pool is globally co-ordinated and chooses its own size based on instructions from some global co-ordinator instead of having the programmer specify the size. I anticipate this will make nearly no difference to actual end-user perceived performance because the cost of having many threads in the runqueue just isn't that high. This is certainly true on Linux and I'd imagine it should also be true on other platforms, although it's definitely the case that Linux threads are unusually cheap.

      Let's take an example of a program I recently wrote that happens to fit this very specific model of parallelism. I have a program that downloads and "installs" a sample library called Cinematic Strings. This program is written in Java for time and portability reasons - it had to run on MacOS and Windows, and it was being written quickly for my brother. The samples come in an encrypted and losslessly compressed form, so the program needs to download, decrypt, decompress and watermark the samples as quickly as possible.

      This is a classic example of "easy" parallelism - lots of small tasks that are entirely independent. It's very easy to make such a programs performance scale linearly in the number of CPU cores. It uses a thread pool sized to the number of CPU cores, with a "controller" thread that unpacks samples from a downloaded ZIP file and sends them to the pool in order to keep it fed. The pool is statically sized and does not change. The threads are marked as low/non-interactive priority. When this program is running then, it is capable of saturating every CPU core on the system.

      So what happens when the system gets additional load put on it, for instance, if you start a program whilst the decompression is running? Well, the kernel (which is already aware of global system load) can decide to prioritize the interactive GUI threads ahead of the explicitly low priority decompression threads. These threads are kicked off the CPU whenever something more important needs them and placed into a queue, waiting to be let back in. However their state is preserved exactly, so as a programmer I don't need to be aware of this.

      What happens if my installer is running, and somebody else tries to also saturate the CPU, perhaps somebody runs a game or simulation for instance? Then the kernel will ensure my program is effectively paused (or only runs in the gaps where no other thread from the higher priority task can run). It won't be completely paused but the impact on the other app should be minimal. In a GCD world, my app would receive a message to resize the pool downwards. This would have the advantage of freeing up a bit of memory used to holds the threads state, but if the kernel wanted to get REALLY aggressive it could already just pause the threads entirely and swap out their state to disk. I don't know of any kernels that actually are that aggressive with respect to low priority threads, but it's theoretically possible.

      Anyway, I am rambling. The Ars Technica article says

      Perhaps surprisingly, one of the most difficult parts of extracting maximum performance using traditional, manually managed threads is figuring out exactly how many threads to create. Too few, and you risk leaving hardware idle. Too many, and you start to spend a significant amount of time simply shuffling threads in and out of the available processor cores.

      But I've done a fair bit of multi-threaded programming and frankly this question has never even come up. I've never seen a multi-threaded program bottleneck on context switch speed - you will blow your RSS limits and start paging due to all the stacks far before reaching that point, unless you're programming s

    26. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 0

      They're too busy culture jamming Apple stores and posting on Slashdot to code, apparently.

    27. Re:Multicore Enhancements!! :) by IamTheRealMike · · Score: 0, Troll

      Let's be clear, GCD provides Objective-C with the features Java has had for over a decade now. The only difference is that thread pool sizes are globally co-ordinated, but as I mentioned in a different post further up, I think this is a gimmick and of all the problems I've had writing multi-threaded code, global co-ordination of thread pool size would have solved none of them.

      There's absolutely nothing new or cool about thread pools and closures. Java developers, in fact anybody working in a modern high level language, have taken this for granted for a long time. If you want to see the successor of the BeOS API take a look at the Android API some time, which provides the same closure/invoke systems that GCD does along with a lot more. Android was designed in part by a bunch of former BeOS folks and can be seen as a simplification of that API whilst retaining its power for those who are able/willing to use threads.

    28. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 1, Interesting

      It is not the context switch that is the bottleneck for the performance. Dependencies are. I give you an easy example. Assume you have 2 Cores and 4 tasks. Two tasks, lets call them A and B, are trivially parallel. They don't depend on anything and they are no requirement for anything. And then there is task D that depends on task C. Assume all tasks need the same time t and context switches are for free.

      You would just throw A, B and C at the processor at the same time, because you say number of threads doesn't cost much. Because D depends on C you will start this after C is finished (probably in the same thread, but that is not important here). Because there are only 2 cores the 3 starting tasks are finished after 3/2 t. After that D is started and needs another t. So the sum of time is:

      5/2 t

      Now we make a slightly smarter aproach. We use a central manager and we tell him all the tasks at the beginning and we tell him about the dependencies. The manager also knows about the number of cores. Let's assume we have implemented a quite trivial heuristic: the priority of a task equals the number of tasks that depend on it (higher priority means it is scheduled earlier).

      So the manager would schedule task C first, and because another core is available he schedules task A and doesn't schedule B because there is no capacity for it (w.l.o.g.). After time t C and A are finished and the manager schedules B and D. Their computation takes another t. So the total processing time is:

      2 t < 2.5 t

    29. Re:Multicore Enhancements!! :) by Anonymous Coward · · Score: 0

      Not that I know of, it seems that GCD is _really_ needed with MacOS X as thread and task creation is very expensive.

      Linux does scale to ten or hundreds of thousands of tasks on even low-spec hardware and the scheduler normally does a good task at scaling them (YMMV though).

      cheers,

    30. Re:Multicore Enhancements!! :) by TheRaven64 · · Score: 1
      No one needs it, but it makes certain categories of application easier to write. GCD is based on the idea that a typical application receives an event from some source and then processes it. Some of the steps involved in processing events can be done in parallel, some can not. GCD manages queues, which are initially fed from event sources and can then (cheaply) pass messages between each other. Some queues are marked as being safe to run in separate threads. The library and kernel, working together, decide the optimum number of threads to create for running the queues.

      Oh, and a Linux port is going to take a long time because Linux has no equivalent of kqueue, which is the foundation of libdispatch. There is no single way in Linux of getting all kernel events, including file descriptor I/O, signals, vnode modification, timers, and so on. There is poll(), which is less efficient than kevent(), for file descriptors but nothing equivalent for the other event sources.

      --
      I am TheRaven on Soylent News
    31. Re:Multicore Enhancements!! :) by ceoyoyo · · Score: 1

      Yes, OpenMP does some of the things that GCD does, but not all.

      As I said elsewhere, Apple hasn't really done anything shockingly new, but they have taken a bunch of existing ideas from different places and put them together into a really nice package.

      Either the Anandtech or the MacResearch article discusses in detail what GCD is, and how it is not OpenMP.

    32. Re:Multicore Enhancements!! :) by wootest · · Score: 1

      You're right, and all you said goes for both Grand Central Dispatch and Parallel Extensions (which will show up as a large part of the .NET Framework in .NET 4); there's plenty of material on this front including all of the advantages, so anyone asking themselves the same question as weicco did, just look it up and be pleasantly surprised.

    33. Re:Multicore Enhancements!! :) by weicco · · Score: 1

      Ah, okay. Thanks for the info. I've written something like this myself. Didn't know there's actually name for it :)

      --
      You don't know what you don't know.
  5. had to look it up.. by TheBilgeRat · · Score: 1

    So, basically this is a tool to streamline concurrent code on multi core machines? Did BSD not have something like this already?

    1. Re:had to look it up.. by cupantae · · Score: 1

      It probably had a less shiny name, though, like libslcon0.8b3

      --
      --
    2. Re:had to look it up.. by UnknowingFool · · Score: 1

      I'm not an expert but I think this now opens up multi-core to individual applications. Before, the OS and system managed which processes should be passed to cores based on threads. Now with GCD, applications can be written that blocks of code could be flagged so that the OS can know to passed.

      The example given in Wikipedia is the analyseDocument method which is used in a document to count the number of words. Without GCD, the main thread that runs this method will have to wait until the method is done. For a small document that delay is not noticeable to the user but will be with a large document. With GCD, the developer can make the method GCD aware. If it takes too long in the main thread, GCD will pass it to another core to handle.

      If my understanding is correct, there are some programs that are multi-core aware but they have to be written at a very low level to take advantage of it. This new API abstracts at a higher level so that all developers have to do is write methods in a certain way.

      --
      Well, there's spam egg sausage and spam, that's not got much spam in it.
  6. Re:Apple's Grand Central Dispatch Ported To FreeBS by larry+bagina · · Score: 3, Funny

    now it can die in parallel, optimized for the number of cores and other system activity.

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  7. Re:Apple's Grand Central Dispatch Ported To FreeBS by Anonymous Coward · · Score: 2, Insightful

    Netcraft confirms it: This joke is dying.

  8. In other news... by Anonymous Coward · · Score: 0

    Package XYZ ported from Ubuntu to Debian!

    1. Re:In other news... by Anonymous Coward · · Score: 0

      The key here is the code behind grand central dispatch is not GPL compatible, so Linux will probably never get this code. This means MOST high performance computing centers will now be looking primarily at OS X (and maybe FreeBSD) for their future needs, rather than Linux. If you are a fan of TRULY FREE software, then this is great news. If you are Richard Stallman, then its time to go cry into your beer.

    2. Re:In other news... by wootest · · Score: 5, Funny

      Richard Stallman does not cry into his beer. Microsoft cries into their beer. Richard Stallman cries into his freedom.

    3. Re:In other news... by DurendalMac · · Score: 1

      I'm sure it will come to Linux in some shape. You might not see it bundled and it may never work with every distro, but not everyone in the Linux community is as much a fanatic as RMS.

    4. Re:In other news... by Lars+T. · · Score: 0

      Richard Stallman does not cry into his beer. Microsoft cries into their beer. Richard Stallman cries into his freedom.

      Freedom is just another word for having no beer?

      --

      Lars T.

      To the guy who modded me down from perfect to terrible Karma - Apple haters still suck

    5. Re:In other news... by Neurotic+Nomad · · Score: 2, Funny

      "Freedom" is what he calls his beard.

    6. Re:In other news... by Zaiff+Urgulbunger · · Score: 1

      How does this fit in with Debian now also providing a FreeBSD kernel? I'm assuming that the FreeBSD kernel uses a BSD licence... but I might well be wrong... but assuming it does, I would guess GCD would be fine?

    7. Re:In other news... by harlows_monkeys · · Score: 2, Informative

      The key here is the code behind grand central dispatch is not GPL compatible [arstechnica.com], so Linux will probably never get this code

      That's not quite correct. There are two parts to GCD: libdispatch and the kernel support. The kernel support is MIT license, so is compatible with GPL. Besides, the kernel component wouldn't be ported anyway--it would be rewritten from scratch if one were doing GCD Linux, so the license doesn't matter.

      Libdispatch is Apache license. It runs in the applications, not the kernel, so the kernel being GPLv2 is irrelevant. What's relevant are the licenses of the applications that might want to use libdispatch. Many of those will be licensed as GPLv2 or later. Those are OK, because Apache license is compatible with GPLv3.

      Finally, if libdispatch were to be included as a standard part of Linux, even GPLv2 code could dynamically link to it, because it would fall under the system library exception.

    8. Re:In other news... by DuckDodgers · · Score: 1

      There's nothing stopping the Linux kernel team or a third party from implementing an equivalent feature for Linux. It may not happen overnight, but if the interest is there it will be done.

      And unless someone has benchmarks, I suspect the performance edge of Grand Central Dispatch isn't going to obsolete Linux - or for that matter, Microsoft Server - overnight.

    9. Re:In other news... by ClosedSource · · Score: 1

      Yeah, you beat me to it. Sounds like another case of confusing copyright with patents.

    10. Re:In other news... by complete+loony · · Score: 1

      Richard Stallman does not cry into his beer. Microsoft cries into their beer. Richard Stallman cries into his speech.

      Fixed that for you.

      --
      09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
    11. Re:In other news... by wootest · · Score: 1

      So, in other words, sobbing.

      And yeah, I messed the simile up.

    12. Re:In other news... by Anonymous Coward · · Score: 0

      They certainly will do this and it will not be compatible with libdispatch and somehow this will be great allthough it is not portable to other platforms.

    13. Re:In other news... by TheRaven64 · · Score: 1

      Libdispatch is Apache 2 licensed, not BSD licensed. There is no legal issue porting libdispatch to Linux (although the lack of sane interfaces on Linux means that there are technical issues; there's nothing equivalent to kqueue/kevent, so you'd have to go via a - slow - wrapper library). The issue is that GPL'd applications can not depend on it. Not really a problem; they also already can't depend on any of the other nice Apache 2 libraries, so this is just one more reason to avoid the GPL for your code.

      --
      I am TheRaven on Soylent News
    14. Re:In other news... by Eivind+Eklund · · Score: 1

      The key here is the code behind grand central dispatch is not GPL compatible [arstechnica.com], so Linux will probably never get this code

      That's not quite correct. There are two parts to GCD: libdispatch and the kernel support. The kernel support is MIT license, so is compatible with GPL.

      Assume you're going to distribute a large program on an embedded device, with paper documentation along with it.

      Assume a program put together with pieces from five hundred of other sources, following the promise of open source.

      Assume these sources are all licenses with the GPLv2. How many pages of documentation do you need to distribute with the embedded device to comply with the license?

      Assume these sources are all licensed under different variations of the MIT/BSD license. How many pages of documentation do you need to distribute with the embedded device to comply with the licenses?

      What extra cost do you think this adds to each device sold?

      Eivind.

      --
      Doubting the existence of evolution is like doubting the existence of China: It just shows that you're uninformed.
    15. Re:In other news... by Anonymous Coward · · Score: 0

      Yeah, of course proprietary software vendors ALL use the same license, and there's nothing tricky in mixing-n-matching them.

  9. Comparisons? by PhrostyMcByte · · Score: 1

    Has anyone written a comparison of GCD, Intel Thread Building Blocks, and VC++ 2010's own task-based concurrency library?

    1. Re:Comparisons? by jhol13 · · Score: 1

      How about Java? (Concurrent maps are very "cute").

    2. Re:Comparisons? by shutdown+-p+now · · Score: 1

      Has anyone written a comparison of GCD, Intel Thread Building Blocks, and VC++ 2010's own task-based concurrency library?

      One thing that comes to mind immediately is that GCD uses Apple's own extension to ISO C for closures (which, IIRC, they have already submitted for standardization - though how long this may take is an interesting question), which means that GCD is usable from a plain C application.

      Parallel Patterns Library (VC++2010 analog) is a strictly C++ library, where tasks and task groups are classes. Consequently, Microsoft also extended C++ with closures for that, but rather than build their own, they simply took lambdas from the draft spec for the upcoming C++0x. So it's kinda "more standard" (though I'm not sure who else actually supports C++0x lambdas at the moment; g++ doesn't), but not usable from plain C.

      It may not be a big difference for Windows developer - virtually no Win32 apps are written in plain C, anyway, so targeting C++ there makes sense. But for Unix-likes, C is still the least common denominator, which is why, I guess, Apple went that way.

  10. Re:Apple's Grand Central Dispatch Ported To FreeBS by omar.sahal · · Score: 2, Funny
    On September 9, 2005, *BSD was finally declared dead. The following obituary appeared in the Berkeley Observer:
    1. * BSD Obituary
    2. * BSD, 28, of Berkeley, CA died Monday, Sept. 19, 2005. Born July 3, 1976, it was the creation of a cluster of pot-smoking hippies who went to Illinois and came home with a reel of tape. Rather than smoke the tape, they uploaded it and hacked on it a little.
    3. * BSD was known for its C shell and early TCP/IP implementation. After being banished from UC Berkeley, it was ported to the x86 platform, where it fell into the hands of heavier pot-smokers who liked to argue. Soon, the project had splintered into 12 different Balkanized projects. Until its death, there was almost constant fighting in and amongst these groups, sometimes degenerating into out-and-out fistfights.
    4. * BSD is survived by its superior, Linux, as well as several commercial unix implementations. It may be missed by some who knew it, although most of them are said to be mere OS dilettante dabblers.
    5. A funeral will be held at 2 p.m. Thursday, Sept. 22, at the Berkeley Chapel on the UC campus, with interment to follow via the burning of the original *BSD tapes and scattering of the ashes over the San Francisco Bay. The Rev. Lou "Buddy" Stubbs will officiate.
    6. The family will receive friends from 7 to 8 p.m. Wednesday, Sept. 21, at the funeral home.
  11. No because they are different by SuperKendall · · Score: 3, Informative

    GCD is a mechanism to let one central authority dispatch threads across multiple cores, for all running applications (including the OS).

    The other two things you mentioned are ways for programs to more easily use multiple threads, but they are still threads under the main process and not centrally managed - so you have to decide blind how much of the system you can take for your threading needs.

    You can compare the Blocks syntax to ways those two systems specify work units to be done in parallel, but that is just a part of the story.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:No because they are different by VGPowerlord · · Score: 1

      GCD is a mechanism to let one central authority dispatch threads across multiple cores, for all running applications (including the OS).

      er... isn't that what modern preemptive multi-tasking OSes already do?

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    2. Re:No because they are different by 99BottlesOfBeerInMyF · · Score: 2, Insightful

      GCD is a mechanism to let one central authority dispatch threads across multiple cores, for all running applications (including the OS).

      er... isn't that what modern preemptive multi-tasking OSes already do?

      Sort of, but GCD is about what application developers can do. Using current development methods the average developer decides how many threads to spawn and the OS tries to give them all equal priority. Further if you break your app into too many threads performance drops because of management issues. If you break it into fewer threads than there are cores, cores sit idle.

      GCD lets app developers break up their app into chunks that can be threads or can be the same thread and let the OS decide how far to break it up and what to send to what core and what to send to the GPU. It basically lets developers who use good practices fire and forget apps and not have to really worry about profiling and optimization for cores.

    3. Re:No because they are different by wootest · · Score: 1

      On a thread level, yes. GCD works with tasks/jobs on a smaller level. I don't know if it actually manages its operation system-wide, but it could certainly do it more efficiently with more metadata and finer-grained units of work.

    4. Re:No because they are different by init100 · · Score: 1

      and the OS tries to give them all equal priority

      Um, no. At least Linux gives I/O-bound threads higher priority than CPU-bound threads, so that when a thread that is blocked waiting for I/O has some data to process, it preempts any running CPU-bound thread. Whether a thread is I/O-bound or CPU-bound is determined dynamically, by looking at the execution pattern.

    5. Re:No because they are different by norton_I · · Score: 3, Interesting

      GCD is a mechanism to let one central authority dispatch threads across multiple cores, for all running applications (including the OS).

      This is what most people talk about, and what is most obvious from the name, but it is not the interesting part of GCD.

      The interesting part of GCD is blocks and tasks, and it is useful to the extent which it makes expressing parallelism more convenient to the programmer.

      The "central management of OS threads" is marketing speak for a N-M scheduler with an OS wide limit on the number of heavyweight threads. This is only useful because OS X has horrendous per-thread overhead. On Linux, for instance, the correct answer is usually to create as many threads as you have parallel tasks and let the OS scheduler sort it out. Other operating systems (Solaris, Windows) have caught up to Linux on this front, but apparently not OS X. If you can get the overhead of OS threads down to an acceptable level, it is always better to avoid multiple layers of scheduling.

    6. Re:No because they are different by 99BottlesOfBeerInMyF · · Score: 1

      Um, no. At least Linux gives I/O-bound threads higher priority than CPU-bound threads, so that when a thread that is blocked waiting for I/O has some data to process, it preempts any running CPU-bound thread.

      Okay, that was an oversimplification. The point being, the app doesn't have information about the system it is running on unless it does complex polling and it doesn't have information about the OS and other application's threads, to schedule them based upon need without creating threads that only increase management overhead.

    7. Re:No because they are different by Darinbob · · Score: 2, Insightful

      Much of what the GCD descriptions seem is "let's compare this well designed system to a badly designed system, and by implication presume that all threading schedulers are also badly designed". Ie, the comment about how Mac OS wastes so much space for each thread is entirely irrelevant here, except to say that on the Mac OS itself you will get better performance with GCD for some situations. It says nothing about better designed threading systems (ie, on embedded and real time systems where no one is storing 512K for a mere thread). It's comparing light weight threads to heavy weight threads.

      It seems to solve the problem of what happens when you've got too much work for each processor is to make things more fine grained. Lots of tiny tasks spread around a few threads on just the right number of processors, rather than lots of threads. You've essentially just got a scheduling problem, you can have an academic career doing this stuff. Figuring out which sets of tasks have priority over others is not that much different than figuring out which applications threads have priority over other threads (ie, is the app with 6 threads more important than the one with 4 threads if you've only got 8 processors).

      Splitting threads into smaller chunks, if you can rearrange your app structure is one approach to this. Your long running threads that talk to each other are now split into smaller units that talk to each other, only you've got more ways to arrange them. Essentially you're going from very coarse grained parallelism to a finer grained parallelism. which gives more flexibility. But people have been doing this stuff and dealing with its problems for decades. You run into the dusty deck problem again, only in a more modern context. Ie, you tell customers you can speed up their code on your parallel machine and compiler by a factor of X, only they have to rewrite things somewhat, and most customers find that too difficult or their algorithm isn't easily parallelized.

    8. Re:No because they are different by Anonymous Coward · · Score: 0

      >> 'If there were no Apple, it would be necessary for Microsoft to create one.' (apologies to Voltaire)

      If there were no Apple, we would not have had to deal with fanbois like you.

    9. Re:No because they are different by ClosedSource · · Score: 1

      I don't claim that Windows thread pools are equivalent to GCD, but you can have the OS handle asynchronous tasks using the thread pool without having to concern yourself with threads explicitly.

    10. Re:No because they are different by 99BottlesOfBeerInMyF · · Score: 1

      Much of what the GCD descriptions seem is "let's compare this well designed system to a badly designed system, and by implication presume that all threading schedulers are also badly designed".

      That was not my intention, but I can see where you'd get that idea from my oversimplification. I was trying to point out a couple of main points. One, GDC is a thread pool that is aware of all the threads from the OS and all the apps and the available hardware resources before threads are created. Two, GDC enables developers to easily make their existing applications more fine grained tasks with little work.

      Essentially you're going from very coarse grained parallelism to a finer grained parallelism. which gives more flexibility. But people have been doing this stuff and dealing with its problems for decades.

      Absolutely, they have, but in actual practice without really using the two items I mention above. Theoretically it would be great if each app developer wrote perfect programs with tasks broken up just right for performance on a system. Realistically, they haven't had very easy to use libraries and systems to do this. A big part of what makes GDC actually useful is the really, really simple syntax for modifying existing programs.

    11. Re:No because they are different by functor0 · · Score: 1

      GCD sounds exactly like Microsoft's "Concurrency Run-time Resource Manager" to me. Except they've already incorporated it into the kernel while MS has just started mentioning about incorporating it into the NT kernel for future releases.

    12. Re:No because they are different by kojot350 · · Score: 2, Informative

      Guess where they got this idea...

      --
      [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*
  12. OpenMP by jipn4 · · Score: 1

    It's unclear that this buys you much over OpenMP 3.0. GCD gives you a little bit more flexibility, but that's not needed in many applications, and GCD is quite inconvenient without closures.

    1. Re:OpenMP by Curate · · Score: 1

      True, OpenMP may be better in some cases. Apple is not aiming to optimize for every case here. Rather, they are aiming for the greatest common denominator.

    2. Re:OpenMP by fred+fleenblat · · Score: 2, Interesting

      it seems like the ability to share work across machines, not just cores, would be a critical difference.

    3. Re:OpenMP by GrahamCox · · Score: 1

      GCD is quite inconvenient without closures

      Except that it does have closures, only Apple prefer to call them blocks. The Cocoa APIs have been extensively revved to include many block-based enhancements to existing APIs that previously used more awkward callbacks.

    4. Re:OpenMP by angelbunny · · Score: 1

      I personally haven't used openMP before so my level of ignorance is high but is openMP dead? Not because of grand central but because of openCL. Doesn't openCL take everything in openMP and allow the dev to work with more than just CPUs?

      I know I'm being a bit offtopic here but seriously: Is there any reason to use openMP any more now that openCL exists?

  13. GCD is not multithreading, it's thread management by diamondsw · · Score: 5, Informative

    Grand Central is not introducing multithreading - it's introducing comprehensive thread management. So, how many threads are you going to spin for that task? Too many, and you waste a lot of time on thread management and preemption. Too few, and you have processors sitting idle. Now how will you handle this with multiple CPU's? Multiple cores? Hyperthreading? Different cache amounts and layout? OpenCL and GPU processing? Do you know what the rest of the operating system is doing to plan appropriately?

    In short, your program can at best make a stab at these issues, and possibly even do a reasonable job if you put a lot of time, effort, and profiling into it. Or you could just use GCD, and let the framework handle it all for you, regardless of whether you're on a Core Solo Mac Mini or a Mac Pro with mutliple OpenCL graphics cards.

    It's good stuff. And Apple gave it to the community (much like WebKit enhancements, launchd, etc).

    --
    I don't know what kind of crack I was on, but I suspect it was decaf.
  14. Re:GCD is not multithreading, it's thread manageme by Anonymous Coward · · Score: 0

    Or you could just use GCD, and let the framework handle it all for you, regardless of whether you're on a Core Solo Mac Mini or a Mac Pro with mutliple OpenCL graphics cards.

    I also think it's a great idea because it's a library. Meaning that if it is updated for speed, stability, etc. it can be incorporated automatically on the next compile. It probably won't benefit single cores at all, but when we start using octal cores this kind of software will be needed, and embraced.

  15. What is this? by RightSaidFred99 · · Score: 1

    Can someone explain how this is different from a normal OS with kernel level threads and not userland threads? What can this do that e.g. Windows threading, native posix threading (NPTL) in Linux, etc... Is this just apple "inventing" kernel level threads or is it something new?

    1. Re:What is this? by Anonymous Coward · · Score: 0

      My understanding is that this is more like a thread manager. It automatically starts up the necessary number of threads and manages what those threads do. Apple is a desktop system, so this is aimed at making it easy to build a desktop application thats automatically adapts to make the best use of available cores and CPUs. It offers nothing over other threading systems, other then being easy to use.

    2. Re:What is this? by 99BottlesOfBeerInMyF · · Score: 1

      Is this just apple "inventing" kernel level threads or is it something new?

      This is Apple making optimization of threading to multiple cores and GPU's easy for developers. This is a library to take work off the shoulders of developers for making faster, more efficient programs by letting developers chunk up their app and letting the OS (which has more information) make choices for the applications as to what becomes a thread. It is not a fundamental architecture change or anything new on the level you're talking about.

    3. Re:What is this? by Anonymous Coward · · Score: 0

      You know what, I knew people were going to ask what this is, so I had a link in the original submission that went to Apple's technology page that goes into detail, but the editor removed it.

      Basically, this framework allows the operating system to manage a global pool of threads based on available system resources, and your application submits blocks of work which the operating system will assign to a thread and run as needed. Normally, an application has to manage its own threads (an expensive operation) and try to figure out how many threads it needs to use. One of the difficulties of concurrent programming is that too many or too few threads can affect performance.

      It's also convenient for the programmer to be able to submit a block of asynchronous code in a single function call. It's really a very easy API to use.

      Posted anonymously because my account has been modbombed into oblivion and can't post anymore.

    4. Re:What is this? by ceoyoyo · · Score: 1

      It's a system of centralized thread queues combined with a nice syntax for easily creating work units to feed to those threads. Yes, bits and pieces of GCD are available in other ways but, as is usual for Apple, they've taken a bunch of existing ideas and put them together into a really nice, integrated package.

    5. Re:What is this? by angelbunny · · Score: 1

      Think of it like this: You want to thread your code if possible to make it productive. You also want your code to be designed for the future. Today most computers might have 2 to 4 cores but 5 years from now it might be 32 cores. Because of this you make your program have tons of threads. Now your know your code is ready for multi core and for the future!

      The problem is threads have a very large overhead. As I see it (and I'm not an expert) it isn't much processing overhead but more memory overhead. This is why in the last couple of years cpus have had giant caches. That way it can hold all of that thread data. If your cpu needs to swap data around because it is cluttered with thread overhead then it looses efficiency and can easily turn into a slug compared to what it can be. Look at Vuze (Azureus) for example. It has approx 220 to 260 threads at any given time. I'm on a core 2 duo. Why doesn't it have 2 threads? 260 threads just overwhelms any current cpu to the point where people bitch about it and move to an alternative like torrent(utorrent). If those 260 threads where queues then on my core 2 duo it would probably be 2 threads total for every program running on the system using GCD. No extra bloated overhead. If I was on a 32 core system then it would most likely be 32 threads. GCD manages tons of queues into a thread.

      It is not only far more productive to do this but the developer does not have to worry about restricting his or herself when it comes to splitting the tasks up.

  16. Nope by SuperKendall · · Score: 1

    er... isn't that what modern preemptive multi-tasking OSes already do?

    Modern OS's move applications or (even threads) across different cores. But applications can have many threads, and the threads until now have been mostly managed by the applications themselves. The choice to spin off 10 or 100 threads? Up to the application. And that choice was made without the application being able to understand what choices other applications had made... the OS was left to manage as best it could with a large pile of threads, or sometimes apps with no threads that could just run on one core.

    With GCD, instead you simply create as many threads as you like, and the central manager decides how many can be run across all the cores. The other part (Blocks) simply makes is easier to define the parts that can run off in separate threads, as noted that is more comparable to the other libraries because you want to encourage every app to have some parallel components. But the other approaches run back into the same problem that once you have defined the parts that can be run in parallel - how many threads should you spawn?

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:Nope by dgatwood · · Score: 1

      With GCD, instead you simply create as many threads as you like, and the central manager decides how many can be run across all the cores.

      Close.... With GCD, you don't create any threads. You create work queues. Those work queues may or may not be backed by one thread, ten threads, or thirty threads, depending on the OS, depending on the number of CPU cores, depending on the number of other processes competing for CPU time.... You get the picture. The point of GCD is that work queues are nearly free, with lockless synchronization used wherever possible to maximize performance, and designed in a way that encourages lockless data flow design patterns instead of procedural thinking, thus leading to code that is inherently easier to parallelize.

      The other part (Blocks) simply makes is easier to define the parts that can run off in separate threads,

      I would have said that blocks make it possible to pass stack-local data into what amounts to a callback routine, and other syntactic sugar, but yeah.

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

  17. About time by interval1066 · · Score: 0, Troll

    Frankly I think its a good thing. The BSD code tree is so old parts of it were rotting from the core. This may inject a vigorous new root into the tree. A sort of BSD for the 21st century perhaps.

    --
    Python: 'And then suddenly you have a language which says "we're all stuck with whatever the whiniest coder wants".'
    1. Re:About time by Anonymous Coward · · Score: 0

      Kind of like injecting a vigorous nigger cock into cmdrtaco's diseased asshole.

  18. Re:GCD is not multithreading, it's thread manageme by 99BottlesOfBeerInMyF · · Score: 1

    ...It probably won't benefit single cores at all...

    Actually, it should reduce management overhead for applications on a machine using a single core.

  19. Re:Apple's Grand Central Dispatch Ported To FreeBS by Anonymous Coward · · Score: 1, Insightful

    Meh..BSD isnt dead, pot smoking is good, and Linux is just for broke rejects who are mad cause they cant afford MS. Its hardly superior to anything, and the only reason it continues to thrive is because the developers make it easy for tards who need a GUI.

  20. Re:GCD is not multithreading, it's thread manageme by mwvdlee · · Score: 1

    Do I understand it correctly if I oversimplify it as "centralized thread pool"?

    --
    Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
  21. GCD also replaces most synchronization / locking by QuantumFlux · · Score: 1

    The other often-overlooked advantage of GCD is that submitting work to a queue is thread-safe, queues themselves are lightweight, and queues can be made internally-serial but parallel to all other queues. Apple's documentation has a lot of good examples of how to use this structure to eliminate almost all locking code (which is usually pretty heavyweight). If you need to serialize access to a resource, just create a serial queue and any other queue can send tasks to it without worrying about any synchronization.

    As someone who's struggled with performance from trying to determine how fine-grained to make locks, this seems like an awesome approach.

  22. Re:GCD is not multithreading, it's thread manageme by wootest · · Score: 1

    It has one, but it's not "just" one. For one thing, it's got an event model for creating and coalescing jobs to automatically schedule on a queue, for watching signals and I/O activity. There's more than that, too, like being able to create new queues, target them onto other queues and pause a queue for further execution.

  23. Missing Slashtod tag: "greenspun". by Kaz+Kylheku · · Score: 1

    Awesome! They have almost reinvented lexical closures, etc. In another ten years this will be as awesome as using continuations for UI navigation in a web framework, which was done yesterday.

  24. Thank goodness for the GPL by Anonymous Coward · · Score: 4, Funny

    Thanks goodness for the GPL, or we might never have convinced Apple to release its code so that FreeBSD could use it!

    Wait... what is that? Oh, nevermind then...

    1. Re:Thank goodness for the GPL by petrus4 · · Score: 1

      Thanks goodness for the GPL, or we might never have convinced Apple to release its code so that FreeBSD could use it!

      Wait... what is that? Oh, nevermind then...

      I have mod points, and I could have just modded this up; however, I am committed to moderation with integrity, however much I might agree with the statement being expressed.

      I will, however, simply say this.

      BSD was here before you, Richard Stallman. It will be here after you.

    2. Re:Thank goodness for the GPL by Anonymous Coward · · Score: 0

      petrus4, while I deeply appreciate your unyielding commitment to integrity in moderation, if such a calculation actually entered into your assessment of how to mod my post then you were treating my smart-alec remark with way more seriousness than it deserved. ;-)

    3. Re:Thank goodness for the GPL by Anonymous Coward · · Score: 0

      GCC is GPLed and they used GCC to implement this thingie. Maybe they could have neglected to release parts of the system, but those parts that are tied to GCC they were forced to release.

    4. Re:Thank goodness for the GPL by TheRaven64 · · Score: 3, Informative

      Clang is BSD licensed and, unlike GCC, supports blocks on FreeBSD and Linux, as long as you have the relevant runtime library. Etoile has been shipping one (MIT licensed) for about six months. Libdispatch is new code from Apple and is Apache 2 licensed, which is incompatible with the GPLv2 (GPLv3 has a special exemption for it).

      --
      I am TheRaven on Soylent News
    5. Re:Thank goodness for the GPL by petrus4 · · Score: 1

      petrus4, while I deeply appreciate your unyielding commitment to integrity in moderation

      I just don't want to be a hypocrite, is all. I wouldn't know how many times I've had comments modded down by Debian/FSF people, simply because they disagreed with what I was saying.

      It annoyed me, and I considered it cowardly; so I'm not going to moderate based on whether or not I agree with the poster.

    6. Re:Thank goodness for the GPL by petrus4 · · Score: 1

      I notice that the FSF cowards are abusing the moderation system again, using their favourite, "Overrated," which is of course shorthand for, "expressing an opinion contrary to our mind control." That particular tag needs to be removed from the list, methinks.

      Do your very worst, FSF. Be tireless in attempting to suppress the opinions of those who believe counter to the monster that leads you. You will ultimately accomplish nothing other than your own continued humiliation.

      Richard Stallman's is not the first brand of tyranny that has needed to be overthrown; it will not be the last.

    7. Re:Thank goodness for the GPL by Anonymous Coward · · Score: 0

      Just to check that I understand: are you saying that even if you think that a post has or lacks merit independent of the point being made, when you have strong feelings of agreement of disagreement with that point you still recuse yourself from moderating the post in order to guard your moderations from bias?

      If so, that is a little extreme in my opinion, but certainly reasonable given your (justifiably) strong feelings on biased moderations. :-)

    8. Re:Thank goodness for the GPL by petrus4 · · Score: 1

      Yes, that is correct.

    9. Re:Thank goodness for the GPL by Anonymous Coward · · Score: 0

      Okidoke then --- thank you for taking the time to clarifying your point. :-)

  25. Re:Apple's Grand Central Dispatch Ported To FreeBS by selven · · Score: 0

    Linux users tend to know how to pirate, so the cost argument doesn't really work. In fact, most people who have linux installed it over (or at least beside) an existing MS system.

  26. you're imagining things by jipn4 · · Score: 2, Informative

    it seems like the ability to share work across machines, not just cores, would be a critical difference.

    Neither GCD nor OpenMP allow you to "share work across machines".

    1. Re:you're imagining things by ceoyoyo · · Score: 1

      No, but Apple's distributed objects implementation lets you do some pretty cool stuff on that front.

    2. Re:you're imagining things by AHuxley · · Score: 2, Informative

      yes Apples has Xgrid to 'share work across machines".
      http://en.wikipedia.org/wiki/Xgrid

      --
      Domestic spying is now "Benign Information Gathering"
    3. Re:you're imagining things by Anonymous Coward · · Score: 0

      Every computer has multiple grid software systems available. What does that have to do with GCD?

      You Apple fanboys really are idiots.

    4. Re:you're imagining things by cbreak · · Score: 1

      What does this have to do with GCD?

    5. Re:you're imagining things by fred+fleenblat · · Score: 1

      It appears that I have confused OpenMP with MPI.
      My apologies.

  27. Re:Apple's Grand Central Dispatch Ported To FreeBS by Anonymous Coward · · Score: 2, Informative

    On their stolen computer next to all the other things they stole from school. They even steal the flies from outside who swarm around their unwashed bodies. linux is the devolvement of humanity - a linux user is like an anti-human - taking the opposite form of what a real human should be. They do not know how to reproduce, they cannot interact with others and they long ago forgot the concept of personal hygiene. They believe communism is something we should strive for and believe klingon is a real language. yes... we know of your type.

  28. But when he shaves by ClosedSource · · Score: 1

    does he get derivative works?

  29. Re:Apple's Grand Central Dispatch Ported To FreeBS by Anonymous Coward · · Score: 0

    i could not have said it better myself. well done brother.

  30. Re:GCD is not multithreading, it's thread manageme by Guy+Harris · · Score: 1

    I also think it's a great idea because it's a library. Meaning that if it is updated for speed, stability, etc. it can be incorporated automatically on the next compile.

    Or, if you're dynamically linked with the library containing it, incorporated automatically when the library is replaced, with no recompilation needed.

    (Yes, I know, automatically picking up improvements and automatically picking up shiny new bugs are both enabled by dynamic linking.)

  31. Re:GCD also replaces most synchronization / lockin by setagllib · · Score: 2, Insightful

    If you're creating a serial queue anyway, you no longer have parallelism. If you have multiple serial queues, you may as well have had multiple threads with no interlocking between them. This is just yet another API to do what competent parallel system programmers have been doing since the first thread.

    --
    Sam ty sig.
  32. It is from APPLE, FFS!! by Anonymous Coward · · Score: 0

    Similar to how iphone was the first real phone, this is the first real threading supergoo invented evaar!! Wasn't the name of Apple a dead giveaway already??

  33. Re:Apple's Grand Central Dispatch Ported To FreeBS by TobiasTheCommie · · Score: 1

    Don't you dare compare me to the parent.. he is certainly no commie...

    --
    Tobias Ussing http://www.nearby.dk
  34. What is the deal with clang? by Anonymous Coward · · Score: 0

    It doesn't even support the full C++ specification. Why are people moving to clang?

    1. Re:What is the deal with clang? by LenE · · Score: 2, Informative

      It will support C++ soon enough.

      The benefits of clang are that it uses llvm as the compiler, which produces better optimized machine code than gcc currently does. Also, it supports Apple's block syntax (kind of like a pointer to a function), which allows things like libdispatch to do its magic. Also, as a C front end, it has much less cryptic error messages, and actually does a pretty good job of finding missed initializations and other hard to find bugs that usually will get caught at the code execution stage.

      You should check out Siricusa's more thorough explanation at arstechnica, in his Mac OS X 10.6 Snow Leopard review. He goes into some detail to show how Apple's use of clang in the new XCode is almost "pornographic for developers..." You wouldn't have the same IDE in BSD or Linux, but the same functionality is there. Someone posted a link much higher in the thread.

      -- Len

    2. Re:What is the deal with clang? by kojot350 · · Score: 1

      Could you show me the link you mention, I can't find it?

      --
      [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*
    3. Re:What is the deal with clang? by TheRaven64 · · Score: 1
      I've contributed a fair bit of code to clang, so I'm biased, but these are may views:
      • The code is much cleaner. I wanted to extend GCC to support Objective-C 2 with the GNU runtime library. It was easier for me to write a complete code generation implementation for GNU libobjc in clang than it was to make simple changes to GCC, coming from no familiarity with either project.
      • Clang is much easier for new developers to modify. Time from first looking at clang code to first diff being accepted was about a week for me, and that's including trying to remember how C++ worked after avoiding it for about 5 years.
      • Clang is more modular. You can easily pull out the front end, for example, and incorporate it in an IDE for syntax highlighting.
      • The modular infrastructure means that there are other interesting projects being built on top of clang, like the static analyser and an indent tool with full semantic awareness.
      • Clang is much faster than GCC and uses less memory.
      • Clang is BSD licensed, while GCC has just become GPLv3. This may not matter to you, but the FreeBSD team doesn't want any GPLv3 code in the base system.
      • Clang uses LLVM for code generation, which comes with a lot of other advantages (it's trivial to write optimisation passes - I've written three) and you get things like link-time optimisation, JIT compilation, and so on for free (there was a demo of a C JIT based on clang at last year's LLVM devmtg).
      --
      I am TheRaven on Soylent News
    4. Re:What is the deal with clang? by Anonymous Coward · · Score: 0

      http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/9

  35. That is more interesting but not what is different by SuperKendall · · Score: 1

    The "central management of OS threads" is marketing speak for a N-M scheduler with an OS wide limit on the number of heavyweight threads

    True enough, but it is the part that differentiates GCD from the other frameworks and thus deserved the most explanation.

    This is only useful because OS X has horrendous per-thread overhead.

    Actually it's useful because threads on all platforms have overhead, which is why the reuse of them by GCD to run these lightweight blocks matters. It's why it's being integrated into BSD.

    The interesting part of GCD is blocks and tasks, and it is useful to the extent which it makes expressing parallelism more convenient to the programmer.

    That is true and what makes it likely we'll see many apps actually take advantage of this where we haven't seen that many apps even bother to thread much before. Frankly even though it will not help with performance (because there is no GCD) I'm excited to have blocks (closures) on the iPhone.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  36. They are not mini-stallmans. They are Apple Haters by SuperKendall · · Score: 4, Interesting

    It's a win/win, but the mini-Stallmans will never see it that way.

    To the contrary: I am a huge fan of Stallman's philosophy and see Apple's work as win/win.

    The people that are complaining are the looney Apple Haters, who try and find any point possible by which to attack Apple - never realizing until it is to late the latest position they are attacking from makes no sense.

    Please do not taint all those of us who respect the GPL with the same brush the Haters paint themselves in corners with.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  37. Re:GCD also replaces most synchronization / lockin by jcr · · Score: 2, Insightful

    This is just yet another API to do what competent parallel system programmers have been doing since the first thread.

    RTFM, and learn what you're missing.

    The point of GCD is that taking advantage of multiple cores becomes much less work. When I say "much less", thinks minutes versus days. Besides the ease of use, the underlying implementation also deals with scaling the queues across the number of available cores on the fly, and makes the management of serial dependencies trivial.

    Another benefit of GCD over managing the threads yourself is performance. Apple changed the implementation of Objective-C's garbage collector from running on a dedicated thread to running in GCD, and picked up a double-digit improvement in the speed of memory recovery.

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  38. duh! by kojot350 · · Score: 1

    Apparently it is a more efficient way of scheduling threads on multi-core systems ...
    ...So this seems good then.

    duh!

    --
    [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*
  39. more mature and better polished? on linux? by Gary+W.+Longsine · · Score: 1

    Oh REAAAAALLLY?

    --
    If you mod me down, I shall become more powerful than you could possibly imagine.
    1. Re:more mature and better polished? on linux? by agnosticnixie · · Score: 1

      YA, RLY, pretty much as usual.

  40. You're missing the point by Gary+W.+Longsine · · Score: 2, Informative

    Apple isn't "sticking with GPLv2" so much as "actively working to replace every last scrap of GPLvn code with BSD/MIT/Apache code." They appear to be under the impression that GPL is unfriendly to business, which impression is defensible. They are investing many programmer years in Clang/LLVM, and soon enough will be liberated from the tyranny of gcc.

    --
    If you mod me down, I shall become more powerful than you could possibly imagine.
  41. Re:GCD also replaces most synchronization / lockin by Anonymous Coward · · Score: 0

    If you have multiple serial queues, you may as well have had multiple threads with no interlocking between them.

    Queues and threads aren't the same thing. The framework manages the size of the thread pool based on the current system state, and queues are assigned to threads automatically. Not only do you avoid expensive thread creation, but you also get an optimal number of threads for the system you're running on.

    This is just yet another API to do what competent parallel system programmers have been doing since the first thread.

    You obviously don't know what GCD is or why it was created and didn't bother doing any reading on it before posting.

  42. Re:That is more interesting but not what is differ by IamTheRealMike · · Score: 1

    Actually it's useful because threads on all platforms have overhead, which is why the reuse of them by GCD to run these lightweight blocks matters. It's why it's being integrated into BSD.

    Well a GCD queue also has overhead, right? The OP is correct - on systems that get threading right (ie not OS X) if you have 200 tasks that can run in parallel, the easiest way forward is to create 200 threads.

    When might you not want to do this? One is if each task has a large associated memory overhead so you don't want the data for every task to be in memory at once. In that case maybe you want fewer threads, and a controller thread that loads data and keeps the thread pool queue long enough that it never stalls but short enough that you use minimal memory.

    Another situation is when a thread is very expensive. This is not true on Linux (at least if you're careful with stack size) and used to be true on Windows but I believe has been improved over time.

    Another situation is where the tasks aren't available all at once. This is just a variant of the first scenario.

    The final one is when a task blocks, eg, reading from disk. In that case you might want a very large number of threads in order to keep the CPUs busy and not waiting around on disk.

  43. They've reinvented SIMULA and PLANC by Anonymous Coward · · Score: 0

    This is exactly what many SIMULA-systems did under the hood. Except SIMULA hid the dirty details better and the language worked on systems that didn't support a "Grand Central Dispatch" (there is even an really inefficient and awfull SIMULA to C compiler).

    I've never programmed in PLANC (the system programming language used by Norsk Data and, as far as I know, the first hardware independent system programming language), but, as I recall, it had similar, if not identical, language constructs as those devised by apple.

    Me think US corporations should start looking at the world around them and stop reinventing things already invented. They would save a lot of money and effort.

  44. Re:That is more interesting but not what is differ by TheRaven64 · · Score: 3, Informative
    Thread creation on Linux is much more expensive than adding a new block to a queue with GCD. This uses 'under 15 instructions'. That's slightly misleading because, on x86, one of those instructions has the LOCK prefix and so is quite expensive, but it's still only marginally more expensive than the cost of a function call. In contrast, creating a thread, at minimum, on Linux has these costs:
    • Allocate at least one page for the stack.
    • Allocate at least one page for the TLS segment and copy its data across.
    • Create the in-kernel data structures required for the thread and insert it into the run queue (this involves a context switch into kernel space and back).

    This is between one and two orders of magnitude more expensive than adding a block to a work queue with GCD.

    Switching between the threads is also relatively expensive. At the very least, you need to save all of the registers and update the stack pointer (probably in response to a timer interrupt, so also factor in the cost of a transition from kernel space to users pace). With GCD, the kernel will give you one thread per CPU for each priority level (or fewer if there are already lots of CPU-bound threads), so you minimise number of context switches.

    This is effectively what an N:M scheduler does, but is slightly better. With an N:M scheduler, you are switching between some threads in userspace, which saves some overhead, but the threads still have largely-disjoint working sets and so you end up with more cache churn (performance killer on modern CPUs). With GCD, you will only be switching between work queues in a given thread between blocks, so there is no cache churn (the old block's cache lines are no longer needed, so you'll kick them out but not then bring them back in immediately). The other nice side effect of this is that, because GCD knows which work queues are assigned to which threads, it can remove locks used for passing messages between work queues if both queues are in the same threads.

    In short, it's an N:M threading model with preemptive kernel threads and cooperative userspace threads. If you read an OS textbook, you'll see that this is, at least in theory, about the most efficient scheduling model possible.

    --
    I am TheRaven on Soylent News
  45. Hottest Selling Bape new style man Shoes Quick G by Anonymous Coward · · Score: 0

                Welcome TO Our Website: Http://www.tntshoes.com

        we are a prefession online store, you can see more photos and price in our website which is show in the photos
            please email me by: www.shopperstrade@hotmail.com
    lv Handbags , dior, D&G channell coach etc $23-32 free shipping.the name of our website is in the photos blow is our website, hellow we are a online fasion shopping mall"

      OUR WEBSITE:
                                                            YAHOO:shoppertrade@yahoo.com.cn

                                                                    MSN:shoppertrade@hotmail.com

                                                                          Http://www.tntshoes.com

  46. FreeBSD technical progress by Anonymous Coward · · Score: 0

    On one hand, FreeBSD is leading the way in adopting cool technology - ZFS, DTrace, PF, and now GDC.
    But, they still do not have a UVC driver, and the 70's installer technology still craps out on some platforms.
    So, on the server, it rules, but on the desktop/laptop, well, it kinda blows.

    1. Re:FreeBSD technical progress by smash · · Score: 1
      Have yet to see the installer crap out actually, and I've been running it on various platforms (including a few then recent laptops, in 06-07) since 2000..

      My experience is that its no more likely to crap out than linux when installing, and if anything less likely, as there tends to be less "automatic" guessing of where/how to install by the installer.

      Its text mode, but it works. GUI installers look pretty, but they're not inherently any better just because they look nice.

      --
      I run: Windows, OS X, Linux, FreeBSD. Just because you have a hammer, doesn't mean everything is a nail.
  47. Explanation at Ars Technica by Midnight+Thunder · · Score: 1

    Ars Technica has a great explanation on Grand Central Dispatch (GCD), and how LLVM and OpenCL fits into the grand scheme of things:

    http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars

    Note: all links from same article, which is 23 proper pages long (not 5 line jobs).

    --
    Jumpstart the tartan drive.
  48. Delegated Answer by Midnight+Thunder · · Score: 1

    See this page on Ars Technica for an explanation: http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/12

    --
    Jumpstart the tartan drive.
  49. Re:GCD also replaces most synchronization / lockin by Anonymous Coward · · Score: 0

    Not quite true. Each serial queue runs in parallel with respect to *other* serial queues. GCD also reserves for itself the right to schedule items from different serial queues on multiple threads or the same thread, should the work be done quickly and a thread become free again. That can be a fairly significant optimization, since you don't need to trap into the kernel (e.g. sleep waiting for more work) if all you're doing is chaining between multiple items of non-blocking work in userland and can detect when there's more work queued up and ready to run. Trapping into the kernel is expensive, and GCD goes to a lot of trouble (both with work scheduling and GCD objects like semaphores) to avoid it, if such is an available optimization (and there are cases where it is, and is not, so it's nice to have something else worrying about those details for you).

  50. Re:GCD is not multithreading, it's thread manageme by petermgreen · · Score: 2, Insightful

    when we start using octal cores
    High end workstations are already shipping with dual quad (8 cores total) and will probablly be shipping with dual hex (12 cores total) in the not too distant future. Quad core is fairly common in the midrange and is even available on some fairly low end machines (e.g. the dell vostro 420). Laptops and low end desktops are generally shipping with dual cores.

    With the exception of nettops and netbooks single cores are pretty much history.

    The bottom line is that cores aren't getting that much faster so most of our gains in computing power are likely to come from more cores and software that needs to get the most out of CPUs is going to need to embrace that and soon.

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  51. WholaseAfflictionn*Shirt for male Inexpensive Sel by Anonymous Coward · · Score: 0

    Welcome to our website: Http://www.tntshoes.com

    We can supply women shoes, brand shoe, safety shoe, clothes, sports products, craftwork and electronic products.
    (1) Material:100% authentic leather
    (2) High quality sports shoes with reasonable prices
    (3) Small trial orders accepted
    (4) With original box,
    (5) Size: US 8-13, Euro 41-47
    (6) Inner packing:1cardoard box

    We have various styles sport shoes on the company website. If you ask for details,
    please visit our website or contact us directly

      OUR WEBSITE:
                                                            YAHOO:shoppertrade@yahoo.com.cn

                                                                    MSN:shoppertrade@hotmail.com