Slashdot Mirror


Apple Open Sources Grand Central Dispatch

bonch writes "Apple has open sourced libdispatch, also known as Grand Central Dispatch, which is technology in Snow Leopard that makes it easier for developers to take advantage of multi-core parallelism. Kernel support is not required, but performance optimizations Apple made for supporting GCD are visible in xnu. Block support in C is required and is currently available in LLVM (note that Apple has submitted their implementation of C blocks for standardization)." Update: 09/11 15:32 GMT by KD : Drew McCormack has a post up speculating on what Apple's move means to Linux and other communities (but probably not Microsoft): "...this is also very interesting for scientific developers. It may be possible to parallelize code in the not too distant future using Grand Central Dispatch, and run that code not only on Macs, but also on clusters and supercomputers."

342 comments

  1. OK, I give up...what is it? by Ritz_Just_Ritz · · Score: 1, Insightful

    Everyone who reads slashdot isn't an OSX ween and has no idea what "Grand Central Dispatch" is. Perhaps a sentence or two describing why it is important/useful would save users from following the link which doesn't provide that info either.

    I want those 5 seconds back! :)

    1. Re:OK, I give up...what is it? by vxvxvxvx · · Score: 1

      I was trying to find out myself... http://forums.macrumors.com/showthread.php?t=775966 That thread seemed to have the most information but I'm still left wondering what the heck it is. Some kind of command queue system that can prioritize?

    2. Re:OK, I give up...what is it? by dave-tx · · Score: 3, Informative

      There's a decent article on wikipedia about it. Basically, it's Apple's multithreading algorithms.

      --

      >> "What would the robut do? Frame someone!"

    3. Re:OK, I give up...what is it? by Lord+Grey · · Score: 4, Informative
      Introducing Blocks and Grand Central Dispatch is what you're looking for.

      From the first paragraph:

      Grand Central Dispatch (GCD) is a revolutionary approach to multicore computing that is woven throughout the fabric of Mac OS X version 10.6 Snow Leopard. GCD combines an easy-to-use programming model with highly-efficient system services to radically simplify the code needed to make best use of multiple processors. The technologies in GCD improve the performance, efficiency, and responsiveness of Snow Leopard out of the box, and will deliver even greater benefits as more developers adopt them.

      libdispatch is the open source implementation of GCD.

      --
      // Beyond Here Lie Dragons
    4. Re:OK, I give up...what is it? by je+ne+sais+quoi · · Score: 3, Insightful
      I want the 5 seconds back that I just spent reading your comment. It would have taken you less time to google it and read the first few sentences of wikipedia than write that:

      Grand Central Dispatch (GCD), named for Grand Central Terminal, is an Apple technology used to optimize application support for multicore processors.[1] It is an implementation of task parallelism based on the thread pool pattern. It was first released with Mac OS X 10.6.

      --
      Gentlemen! You can't fight in here, this is the war room!
    5. Re:OK, I give up...what is it? by Anonymous Coward · · Score: 2, Informative

      It is operating system infrastructure that allows programmers to harness modern programmable graphics hardware and regular CPUs as a single anonymous "multi-threaded" resource.

      The idea being that now GPUs are becoming double precision capable they are looking increasingly like super computers from yester-year and Grand Central Dispatch allows programmers to easily capitalise on this advance.

    6. Re:OK, I give up...what is it? by chetbox · · Score: 1
      From Wikipedia:

      an Apple technology used to optimize application support for multicore processors

      It essentially gives programmers a way to split their code into "blocks" which can be run on different processors. libdispatch then decides which processor to run each "block" on, so that the load is spread efficiently. It's similar in concept to threading except that events can trigger a new work-block to be created rather than a thread waiting for an event.

    7. Re:OK, I give up...what is it? by Jah-Wren+Ryel · · Score: 1

      Everyone who reads slashdot isn't an OSX ween and has no idea what "Grand Central Dispatch" is.

      Yeah, I thought Google bought Grand Central and was trying to figure out how their call routing tech had made it into Apple's hands.

      --
      When information is power, privacy is freedom.
    8. Re:OK, I give up...what is it? by cowscows · · Score: 5, Informative

      ArsTechnica always does a pretty thorough and reasonably technical review of each OSX release, and the latest one gives a pretty good explanation of GCD as well as Blocks.

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

      The GCD stuff in particular starts on page 12, but the previous couple pages give a little bit of useful background on why it's important.

      --

      One time I threw a brick at a duck.

    9. Re:OK, I give up...what is it? by macshome · · Score: 4, Informative

      It's OpenCL that opens up the GPUs to general processing on 10.6. Although GCD certainly plays a role by dispatching threads to those resources.

      You should check out this astounding OpenCL demo here: http://www.macresearch.org/opencl_episode1

    10. Re:OK, I give up...what is it? by Anonymous Coward · · Score: 0

      Everyone who reads slashdot isn't an OSX ween and has no idea what "Grand Central Dispatch" is.

      i would have thought that everybody on google knows how to use google though :P

      ars has a good discussion about it (and much more):
      http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/12

    11. Re:OK, I give up...what is it? by Anonymous Coward · · Score: 0

      I'm pretty sure they are the operations department at Grand Central Station who are responsible for keeping the trains on time (scheduling threads) while preventing collisions (critical sections), traffic jams (deadlocks) and keeping customers happy (UI responsiveness). But then I could just be all wet.

    12. Re:OK, I give up...what is it? by Anonymous Coward · · Score: 1, Insightful

      But the parent is right about the fact that those two sentences should have been part of kdawson's post.

      Not everybody knows everything about every subject, I find it confusing with most of the OSS projects, especially given the weird names they give their stuff.

    13. Re:OK, I give up...what is it? by Anonymous Coward · · Score: 0

      read for comprehension.
      the summary says it clearly "which is technology in Snow Leopard that makes it easier for developers to take advantage of multi-core parallelism."

    14. Re:OK, I give up...what is it? by jo_ham · · Score: 4, Insightful

      "Apple has open sourced libdispatch, also known as Grand Central Dispatch, which is technology in Snow Leopard that makes it easier for developers to take advantage of multi-core parallelism."

      First line of THE SUMMARY.

      I know it's not hip to RTFA, but it's at least a minimum requirement to read the very next line after the title, even while scrolling down eagerly to make a comment.

    15. Re:OK, I give up...what is it? by 99BottlesOfBeerInMyF · · Score: 4, Insightful

      Everyone who reads slashdot isn't an OSX ween and has no idea what "Grand Central Dispatch" is. Perhaps a sentence or two describing why it is important/useful would save users from following the link which doesn't provide that info either.

      Look I'm as annoyed by poor summaries as anyone, but it seems almost reflexive to complain about them these days. The summary clearly said it, "makes it easier for developers to take advantage of multi-core parallelism". I don't care if you've never heard of OS X and no nothing about it. That sentence right there tells you what effect it has and why it's useful. After that it's just details as to where and if it is applicable to some other project. I guess what I'm saying is, I thought this was a pretty decent summary, enough to know if you should read about it.

    16. Re:OK, I give up...what is it? by Gilmoure · · Score: 4, Funny

      also known as Grand Central Dispatch, which is technology in Snow Leopard that makes it easier for developers to take advantage of multi-core parallelism.

      They kinda' snuck that one in.

      --
      I drank what? -- Socrates
    17. Re:OK, I give up...what is it? by Narishma · · Score: 1

      This and the next 3 pages in that review explain it all very well.

      --
      Mada mada dane.
    18. Re:OK, I give up...what is it? by Anonymous Coward · · Score: 0

      I saved those 5 seconds, actually! I didn't even RTFS :D

      captcha: shortcut.

    19. Re:OK, I give up...what is it? by travler · · Score: 1

      "...which is technology in Snow Leopard that makes it easier for developers to take advantage of multi-core parallelism..."

      This seems pretty clear to me, not sure what more you want. Googling 'Grand Central Dispatch' comes up with lots of details.

      Remember this is news for _nerds_. :)

    20. Re:OK, I give up...what is it? by ceoyoyo · · Score: 1

      "which is technology in Snow Leopard that makes it easier for developers to take advantage of multi-core parallelism."

      That's a hell of a lot better than you get from the usual Slashdot summary.

    21. Re:OK, I give up...what is it? by Decameron81 · · Score: 1

      He's right to complain though. It's like when your boss tells you you did something wrong, and you need to fix it. He could fix it himself instead of telling you, and it would be faster, but you wouldn't have feedback to improve your working methods. In this case he's not the boss, but IMO he's right about not describing what GCD is. It is not THAT popular.

      --
      diegoT
    22. Re:OK, I give up...what is it? by Spaham · · Score: 1

      read ars technica's review of snow leopard.
      They have a few pages on Grand Central Dispatch, LLVM etc
      http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars

    23. Re:OK, I give up...what is it? by Anonymous Coward · · Score: 0, Funny

      Marketese not, please. They would describe "shit" as "carefully optimized, easy to use, disposable method to radically simplify the act of residual management".

    24. Re:OK, I give up...what is it? by bonch · · Score: 1

      It's a bit like an easy-to-use thread pool. You submit blocks to queues, and the operating system assigns those queues to a number of threads it determines based on available system resources. It's a very easy API to use, often consisting of only a single function call to pass the block.

      Here's an article with an introduction to GCD along with C examples.

    25. Re:OK, I give up...what is it? by blhack · · Score: 1

      I came here to say exactly this.

      A lot of "web two point oh" people seem to love these sorts of silly names. For some reason, Apple does too...

      It's very frustrating as a non-mac-cultist to see things like "Snow Leopard", or "Grand Central Dispatch" and have no clue what it means. Version numbers guys, use them!

      --
      NewslilySocial News. No lolcats allowed.
    26. Re:OK, I give up...what is it? by leromarinvit · · Score: 1

      Well, he was obviously using the same approach Grand Central Dispatch takes - why google it yourself when you can just dispatch that task to Slashdot?

      --
      Proud member of the Ferengi Socialist Party.
    27. Re:OK, I give up...what is it? by bonch · · Score: 0

      Good thing the fucking article has three links to explanations and tutorials in case you don't know what it is.

    28. Re:OK, I give up...what is it? by Justus · · Score: 1

      I agree, which is why I'm viewing this page in Web Browser 11.4 on Operating System 7.9. Now if you'll excuse me, I need to get back to E-mail Client 4.0 and Text Editor 22.3.

    29. Re:OK, I give up...what is it? by Ilgaz · · Score: 1

      Grand Central and OpenCL are two technologies which really matters in Snow Leopard. If you ask me, those 2 being heavily related to x86 for some reasons is also why Snow Leopard didn't release for PPC G5. It somehow validates Apple's giving up PPC, once more.

        Just like any news about Apple developer things, you should skip the PR/news sites/blogs and go to http://developer.apple.com/ for real information.

      http://developer.apple.com/mac/library/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html

    30. Re:OK, I give up...what is it? by wootest · · Score: 1

      Actually, libdispatch is *the* implementation of GCD so far. It is open source alright, but your sentence could be read as if libdispatch was a watered-down, open source safe version of it, which isn't the case.

    31. Re:OK, I give up...what is it? by larry+bagina · · Score: 1

      Grand Central Dispatch is the program (library/API) name.

      --
      Do you even lift?

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

    32. Re:OK, I give up...what is it? by oatworm · · Score: 2, Funny

      This is all running on kernel 2.6.31, right?

    33. Re:OK, I give up...what is it? by jonaskoelker · · Score: 1

      I want the 5 seconds back that I just spent reading your comment. It would have taken you less time to google it [...]

      I believe his point was that it would take the editors much less time to put up such a blurb than it would take for the first thousand /.'ers to google it. Telling O(n) people to google it instead of having O(1) people do it for them is a net loss (for large enough values of n).

      (Or he might just be a lazy slob, I don't know).

    34. Re:OK, I give up...what is it? by zieroh · · Score: 1

      Version numbers guys, use them!

      Yes, because humans are much better at remembering numbers than symbolic names.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    35. Re:OK, I give up...what is it? by bchernicoff · · Score: 1

      libdispatch is the open source implementation of GCD.

      I misread that as libdispatch is the open source implementation of GOD.
      I got all excited there for a second.

    36. Re:OK, I give up...what is it? by PhunkySchtuff · · Score: 1

      From the summary "...which is technology in Snow Leopard that makes it easier for developers to take advantage of multi-core parallelism"

    37. Re:OK, I give up...what is it? by neccoant · · Score: 1

      Definitely deserves a "Funny" or two.

  2. What? by julesh · · Score: 2, Interesting

    Can somebody explain what this "blocks" is? I mean, C being a block-structured language, I thought it already supported them...

    1. Re:What? by Daniel_Staal · · Score: 5, Informative

      Blocks are sections of program that can be passed around between functions as arguments. They basically allow 'functional' programming in C.

      --
      'Sensible' is a curse word.
    2. Re:What? by 644bd346996 · · Score: 2, Informative

      Blocks are the closest C will probably ever get to first-class functions. They're close enough that you can reap most of the benefits of first class functions.

    3. Re:What? by twoshortplanks · · Score: 4, Informative

      I'd recommend reading the relevant section of the ars technica review of mac os x 10.6

      --
      -- Sorry, I can't think of anything funny to say here.
    4. Re:What? by ThePhilips · · Score: 1

      To me it looked something like a nameless function, which shares same stack with the functions where it is defined.

      Even if it's a dumb nameless function, it could be already very useful. E.g. perl's 'sort {$a op $b} @list' can be more or less directly translated to C's 'qsort( .... ^(const void *a, const void *b){ return a op b; } )'. At least I hope so.

      --
      All hope abandon ye who enter here.
    5. Re:What? by LO0G · · Score: 3, Interesting

      They're basically lambda functions which are a part of C++0x.

    6. Re:What? by heffrey · · Score: 1

      Actually, C is not a block-structured language. You can't declare functions inside other functions.

    7. Re:What? by shutdown+-p+now · · Score: 1

      Also, for the record, the use of term "block" in that sense comes from Smalltalk - which isn't surprising, considering the roots of Objective-C itself.

    8. Re:What? by wootest · · Score: 3, Informative

      They're an alternate implementation of lambda-like technology. Apple's Chris Lattner wrote the first public announcement on blocks and noted: "To head off the obvious question: this syntax and implementation has nothing to do with C++ lambdas. Blocks are designed to work well with C and Objective-C, and unfortunately C++ lambdas really require a language with templates to be very useful. The syntax of blocks and C++ lambdas are completely different, so we expect to eventually support both in the same compiler."

      If only due to type inference, I'd prefer the syntax of C++ lambdas, but Blocks aren't half bad at what they do within the frame of the C model.

    9. Re:What? by SideshowBob · · Score: 1

      There's a significant difference, which is that blocks can have a life beyond the lexical scope that created them. By calling block_copy you get a block that you own. This is useful for things like GCD that keep queues of blocks to run.

    10. Re:What? by Anonymous Coward · · Score: 0

      If a geek needs an explanation as to what it means to be "C-Blocked", it's small wonder they still live in the basement.

  3. Awesome! by gers0667 · · Score: 5, Interesting

    I'm not too well versed in Cocoa development. I pushed some code that should have been in a separate thread into GCD, which requires you to use a block. All in all, I had to add an include, 1 line of code and a closing bracket.

    Apple has made some seriously cool stuff here.

    1. Re:Awesome! by ThePhilips · · Score: 4, Insightful

      Having done some multiprogramming, I have to tell that it is really an end-user technology. Less a tool for developer.

      One of the biggest problems on multi-CPU/core systems if to split appropriately CPUs between applications. That requires quite amount of testing and benchmarking. Then you simply configure max number of threads each application allowed to use. Obviously changing anything at later time when problem was found requires some effort too.

      With GDC that all now is much easier. Available CPU resources are presented to applications in a fashion of real-time batch queue. One doesn't need to configure thread pools per application anymore.

      That was never a problem from software development point of view - we just provide the 'max threads' parameter. But that was always problem from user/operator point of view who has to actually fill in the parameter.

      --
      All hope abandon ye who enter here.
    2. Re:Awesome! by Anonymous Coward · · Score: 0

      Having done some multiprogramming, I have to tell that it is really an end-user technology. Less a tool for developer.

      Having also "done some multiprogramming" (I work in HPC), it's very much a tool for developers as well as the end-user.

      In my case the end user and developer are the same person - me. I'm not alone in this situation.

    3. Re:Awesome! by ThePhilips · · Score: 1

      ~200 lines of code required to implement thread pool for an application is hardly an effort. Three-four hours of coding at most.

      Configuring bunch of applications, each with a thread pool, to utilize system optimally to extract maximum performance out of it - is an effort which has to take every time one deploys the software anew. And in my experience people spend considerable time (weeks) to configure thread pools properly: avoid overload and maximize performance.

      I've seen that many times before. I'm also seeing the same with product sold by my employers: we have at least four applications with thread pools. Coming up for every deployment with the suitable configuration (which depends on business case of customer) is a time consuming process.

      --
      All hope abandon ye who enter here.
    4. Re:Awesome! by Dog-Cow · · Score: 5, Informative

      GCD is entirely a developer technology. It's a library for crying out loud! The end-user never does anything with it.

      The whole point is to make multi-processing easy for the developer.

      I pity the fools who have to use the code you've written.

    5. Re:Awesome! by jedidiah · · Score: 1

      No, it just looks like you are trusting the OS to do that for
      you and to get it right without any input from you. If the OS
      can do that for you as a developer then why can't you do that
      in your own code?

      --
      A Pirate and a Puritan look the same on a balance sheet.
    6. Re:Awesome! by Anonymous Coward · · Score: 0

      ~200 lines of code required to implement thread pool for an application is hardly an effort. Three-four hours of coding at most.

      Configuring bunch of applications, each with a thread pool, to utilize system optimally to extract maximum performance out of it - is an effort which has to take every time one deploys the software anew. And in my experience people spend considerable time (weeks) to configure thread pools properly: avoid overload and maximize performance.

      I've seen that many times before. I'm also seeing the same with product sold by my employers: we have at least four applications with thread pools. Coming up for every deployment with the suitable configuration (which depends on business case of customer) is a time consuming process.

      Sounds like this stuff is very much a tool for the DEVELOPER then.

      Anything that allows me to spend more time thinking about the overall problem, as a solid implementation for some of the nuts and bolts already exists, can only be good for me.

    7. Re:Awesome! by gbjbaanb · · Score: 1

      The question is... how is this different to Intel's Thread Building Bocks, or OpenMP, both of which are better supported and more widely available to non-Mac developers.

      I guess having their own implemntation (for the mac) makes sense, as they can integrate it throughout the OS. I don't know anything about GCD either, but could it be used in Linux to make that a more parallel-friendly OS with less developer effort, and more standardisation of parallel execution?

      Linux is always playing catch-up with Windows features, its could be nice it got something truly fancy that used all those 4096 CPUs it can support :)

    8. Re:Awesome! by ThePhilips · · Score: 5, Insightful

      The question is... how is this different to Intel's Thread Building Bocks, or OpenMP, both of which are better supported and more widely available to non-Mac developers.

      If I'm not mistaken the technologies are for an application.

      GCD can coordinate all applications running on the same system.

      I guess having their own implemntation (for the mac) makes sense, as they can integrate it throughout the OS. I don't know anything about GCD either, but could it be used in Linux to make that a more parallel-friendly OS with less developer effort, and more standardisation of parallel execution?

      Theoretically yes.

      Apple here is in unique position.

      Most software developers care solely about their own application. Old example from the desktop. On Windows I have 7-zip archiver installed. I have dual core CPU and this 7-zip is configured to use the 2 cores. From prospective of software developers it's all what they can do: let users tell how much cores/CPUs can be used. But I also have a video encoding application installed - and also configured to use two cores. If I try to run them both in parallel, that would cause erroneous amount of context switching harming performance of both the tasks. In worst case that might make my desktop completely unresponsive. As user I'm also lazy to reconfigure every time applications how many CPUs they should use.

      Apple itself now produces number of applications which can utilize multiple CPUs (iTunes audio conversion, iMovie/QuickTime/FC video conversion, etc) and obviously they run into the problem that when applications left on their own to decide how much CPU resources they should use, system would overload leading to all the effects. Requiring user to reconfigure all the applications all the time is also kind of stupid.

      Since Apple is in control of the OS and applications - and their own software might suffer from the problem, they went out and implemented the solution: system-wide batch queue with a thread pool. They are still threads - local to the process - but they are scheduled on system-wide basis. You do not need to configure applications how many CPUs they should use - nor applications have to think about: they simply put tasks (to be threads) of the queue of GCD.

      I'm using the 'batch queue' term because this is the closest what exists now. Though classical UNIX batch queues are different in nature: those are processes and they are executed at some unknown point of time. GCD is real-time in its nature and its threads run immediately, unlike traditional batch queues which wait for system to be idle.

      --
      All hope abandon ye who enter here.
    9. Re:Awesome! by rsax · · Score: 1

      Having done some multiprogramming, I have to tell that it is really an end-user technology. Less a tool for developer.

      With GDC that all now is much easier. Available CPU resources are presented to applications in a fashion of real-time batch queue. One doesn't need to configure thread pools per application anymore.

      I'm so glad GDC is available for general use. I can't count the amount of times I've had to help my grandma configure thread pools for each app. She's totally gonna dig 10.6 now that her multicore computing issues have been addressed and on top of that, she can easily download printer drivers too.

    10. Re:Awesome! by BasilBrush · · Score: 2, Insightful

      For the usual reason that OSs handle resources. Because the OS is in a position to share out resources between applications in a reasonable way. If each app does it's own thing, then it's either a free for all, and pretty much guaranteed to be inefficient.

      It also of course has the other usual benefit of libraries. It means that programs don't have to reinvent the wheel every time they write an app. GCD makes writing multi-threaded code using thread pools vastly simpler than before.

    11. Re:Awesome! by Anonymous Coward · · Score: 0

      In ~200 lines of code you don't write a thread pool system wide aware which also integrates easily with C blocks.

      And unless you have a dedicated sysadmin for each of your server, it also won't be dynamically configured.

      So no, GCD does not _only_ solve a configuration issue.

    12. Re:Awesome! by gbjbaanb · · Score: 1

      I understand now - strangely this is one /. thread where I have learned something by reading all the posts! (though I have had to be sceptical about some of them, but there's been a broad consensus about how it works).

      It seems that it is an easier way to implement threading in the apps too, so not only does the OS schedule these as needed, the developer gets to implement his threaded app very easily too. Someone said its "islands of serialisation in a sea of parallelism" (or something like that), and I get that too - its like the old message passing middleware system I used to work on.

      All in all, I think its great, if it can be implemented in the linux kernel too (but with an obj-C interface) then we can all benefit. And Windows will be playing catch-up while Linux devs get all the parallel processing goodness and Windows devs have to kludge up their own mechanisms app by app. (yes, I'm a Windows dev too, but I like the idea of linux getting the better toys nowadays).

    13. Re:Awesome! by Anonymous Coward · · Score: 0

      Your software makes the user create the correct number of threads to the correct number of processors???

      I never want to use it.

    14. Re:Awesome! by wootest · · Score: 1

      Having a shared system thread pool that can spread task load evenly across the entire machine and avoid races when each of the thread pools in a few applications start deciding that they can use much of the CPU for themselves sounds useful to me. Even an optimized application-wide thread pool can't be psychic.

    15. Re:Awesome! by broken_chaos · · Score: 1

      How about we go with the library being a developer tool, but the results of what the library does being of benefit to everyone? It both makes utilizing threads easier for developers, as well as making the OS and applications (when most/all of them use this library) significantly 'smarter' about how much it can be doing at once, generally keeping responsiveness at an acceptable level. It doesn't just improve the development experience - it also improves the end-user experience.

    16. Re:Awesome! by DarkOx · · Score: 1

      I could if I was developing an application that was likely to be they application running on the machine. If I was doing say a database engine I could carefully plan out what to do in which threads and probably come up with my own scheme for scheduling them.

      On a desktop though the OS has a much better shot at it than I do. It know about all the other processes executing, how much time they need and how many threads they are running. I don't get to know any of that as a developer of an application.

      --
      Repeal the 17th Amendment TODAY! Also Please Read http://www.gnu.org/philosophy/right-to-read.html
    17. Re:Awesome! by Anonymous Coward · · Score: 0

      That's the wishful thinking. OSX is light years behind Windows when it comes to thread management: http://msdn.microsoft.com/en-us/library/ms681917(VS.85).aspx

    18. Re:Awesome! by the_B0fh · · Score: 1

      And you don't trust the OS to give you the memory you requested, or clear the memory you don't want anymore or give you the correct block of data from the disk?

      Awesome, I didn't realize you're a microcoder!

  4. Apache and a threading framework by RiotingPacifist · · Score: 1, Redundant

    the question is:
    What license? Apache v2.0
    What the fuck is GCD?

    Grand Central Dispatch (GCD), named for Grand Central Terminal, is used to optimize application support for multicore processors. It is an implementation of task parallelism based on the thread pool pattern
    GCD works by allowing specific tasks in a program that can be run in parallel to be demarcated as blocks.[2] To this end, it extends the syntax of C, C++, and Objective-C programming languages.[2] At runtime, the blocks are queued up for execution and depending on availability of processing resources, they are scheduled to execute on any of the available processor cores[2] (referred to as "routing" by Apple).[3]
    see also
    # Task Parallel Library - comparable technology in the .NET Framework developed by Microsoft.
    # Java Concurrency - comparable technology in Java (also known as JSR 166).

    --
    IranAir Flight 655 never forget!
    1. Re:Apache and a threading framework by Enderandrew · · Score: 1

      Thanks. Now I imagine this might be more useful in BSD, except I'm not sure BSD can incorporate code under an Apache license. Perhaps someone can enlighten me there.

      Honestly, I'm more interested in whether or not this can benefit Linux, but I'm assuming it would take a major rewrite to fit the Linux kernel.

      --
      http://blindscribblings.com - Tasty pop-culture in conceptual fashion.
    2. Re:Apache and a threading framework by MrMr · · Score: 1

      Task parallellism libraries are essentially fancy wrappers around fork-and-exec. That is really old tech, and needs no rewrite.

    3. Re:Apache and a threading framework by samkass · · Score: 3, Informative

      pthreads and fork/exec are the equivalent of assembly language for parallelism compared to GCD. The API makes it easy to create anonymous methods that can be parallelized, have dependencies, be put in serial or parallel queues, etc. Then the OS implementation can prioritize at a finely-grained level based on dynamic resource availability, relative process priority, etc., on a system-wide basis. (The OS implementation of GCD was already open-sourced as part of 10.6's Darwin xnu kernel release last week.)

      It's pretty nifty stuff. And it's good to see Apple continue MacOS X's tradition of openness and support of open source.

      --
      E pluribus unum
    4. Re:Apache and a threading framework by ThePhilips · · Score: 3, Insightful

      It's an old tech. But it's different this time around.

      Old thread pools are per process. This is a thread pool for the whole system. And that's new.

      IOW, with GCD you do not need to configure every application how much threads it should start. Applications do not need to bother with it anymore too: they simply queue batch tasks as they arrive and GCD guarantees that they will be executed. Without overloading system.

      Shortly, GCD is a system-wide replacement for old per-application thread pool configuration. Makes applications simpler and also doesn't force end-user to understand all oddities of multi-programming to get most out of their boxes.

      --
      All hope abandon ye who enter here.
    5. Re:Apache and a threading framework by abigor · · Score: 1

      I really, really wish people would read about technology before making their grand pronouncements about how irrelevent it is.

    6. Re:Apache and a threading framework by oatworm · · Score: 1

      Reading is essentially a fancy wrapper around speaking and memorization. That is really old tech, and needs no restatement. Also, technology is essentially a fancy wrapper around labor and material. That is really old tech, and needs no reworking.

    7. Re:Apache and a threading framework by ardeez · · Score: 1

      >IOW, with GCD you do not need to configure every application how much threads it should start.

      You seem pretty hung up on this issue, but in reality most apps can configure themselves without the need for users ever dinking with the settings. A good algorithm that I've used is create threads in the pool 2 * the number of cores available and have the app expand dynamically to 4 * the number of available cores when really busy. When idle, the thread pool then shrinks to the original computed low-water mark again.

      This works fairly well and means users never have to configure anything, and it will scale up to however many cores your system has available without the user ever having to worry about it.

      But I take your point that an OS managed thread pool will manage OS resources much better, instead we have a situation now where multiple apps all have their own pools and most likely there are loads of threads per process doing absolutely no useful work.

      Also interesting to see in GCD is the two different types of queues, serial and parallel, with the serial queues potentially greatly reducing the number of locks an app might have to manage.

      --
      don't be a spelling loser
  5. GCD is task parallelism by tepples · · Score: 5, Informative

    It's a library for task parallelism using a thread pool, introduced in Mac OS X 10.6 (Snow Leopard). Wikipedia tells all.

    1. Re:GCD is task parallelism by Anonymous Coward · · Score: 0

      Software is currently offered under Apache License, Version 2.0, once people contributed, Apple will change the license to APPLE PUBLIC SOURCE LICENSE as they did with mDNSResponder (bonjour). If they are truly interested to port to other platforms, they should have released under BSD license so that you do not have to worry about patent claims.

    2. Re:GCD is task parallelism by Anonymous Coward · · Score: 0

      No.

      No. No. No. No. No. No. No.

      No.

      NO.

      No.

      You're wrong.

      "The central insight of GCD is shifting the responsibility for managing threads and their execution from applications to the operating system."

      Note that the operating system knows a lot more about resource usage (including number of cores, etc) than an application will, and can schedule appropriately for best response and smoothness and so on.

  6. RTFA by yabos · · Score: 5, Informative

    "We recognize that libdispatch is a new technology and you likely have many questions. Here are some documentation resources for getting started:

    Introducing Blocks and Grand Central Dispatch
    Concurrency Programming Guide
    Grand Central Dispatch (GCD) Reference"

    1. Re:RTFA by yabos · · Score: 1

      Maybe you should RTFC yourself. The links are right there on the page and unless you're a complete idiot you can clearly see it.

      And since it seems you're so damned lazy to click links, the first "Introduction to Blocks and Grand Central Dispatch" says
      "The central insight of GCD is shifting the responsibility for managing threads and their execution from applications to the operating system. As a result, programmers can write less code to deal with concurrent operations in their applications, and the system can perform more efficiently on single-processor machines, large multiprocessor servers, and everything in between. Without a pervasive approach such as GCD, even the best-written application cannot deliver the best possible performance, because it doesnâ(TM)t have full insight into everything else happening in the system."

      If you can't figure out what that means then GTFO this site.

    2. Re:RTFA by MachineShedFred · · Score: 2, Insightful

      I like how you refer to a "cult" but lash out with some disproportionate animosity to something, which you fully admit, you don't know anything about.

      Sounds like pretty cult-like behavior.

      --
      Slashdot still doesnâ(TM)t support Unicode after it was added to the HTML standard in 1997.
    3. Re:RTFA by abigor · · Score: 1

      Rogerborg: voted "Most Likely to Die in a Police Standoff".

    4. Re:RTFA by Rogerborg · · Score: 1

      You'd think, but the fucktards won't even take my 911 calls any more.

      --
      If you were blocking sigs, you wouldn't have to read this.
    5. Re:RTFA by Rogerborg · · Score: 1

      See that thing way, way, waaaay up there in the sky, so far above your head that it's a tiny dot?

      That's the point.

      --
      If you were blocking sigs, you wouldn't have to read this.
  7. Blocks and GDC by Anonymous Coward · · Score: 5, Informative

    Blocks:
    In Snow Leopard, Apple has introduced a C language extension called "blocks." Blocks add closures and anonymous functions to C and the C-derived languages C++, Objective-C, and Objective C++.
    Perhaps the simplest way to explain blocks is that they make functions another form of data. C-derived languages already have function pointers, which can be passed around like data, but these can only point to functions created at compile time. The only way to influence the behavior of such a function is by passing different arguments to the function or by setting global variables which are then accessed from within the function. Both of these approaches have big disadvantages
    Full Read: http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10

    Directly in line with blocks is Grand Central Dispatch (and this is, where blocks become really usefull):
    GDC is a a technology to resolve the concurrency conundrum by giving programmers a very easy way to split tasks into multiple sub-tasks which can then be loaded onto different threads/cpu. All this also works with normal threading, but GDC makes the process far easier, with the intention to prepare OSX for future multicore machines:
    http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/12

    It does so by using blocks as separate tasks:
    http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/13

    "When I first heard about Grand Central Dispatch, I was extremely skeptical. The greatest minds in computer science have been working for decades on the problem of how best to extract parallelism from computing workloads. Now here was Apple apparently promising to solve this problem. Ridiculous.

    But Grand Central Dispatch doesn't actually address this issue at all. It offers no help whatsoever in deciding how to split your work up into independently executable tasksâ"that is, deciding what pieces can or should be executed asynchronously or in parallel. That's still entirely up to the developer (and still a tough problem). What GCD does instead is much more pragmatic. Once a developer has identified something that can be split off into a separate task, GCD makes it as easy and non-invasive as possible to actually do so.

    The use of FIFO queues, and especially the existence of serialized queues, seems counter to the spirit of ubiquitous concurrency. But we've seen where the Platonic ideal of multithreading leads, and it's not a pleasant place for developers.

    One of Apple's slogans for Grand Central Dispatch is "islands of serialization in a sea of concurrency." That does a great job of capturing the practical reality of adding more concurrency to run-of-the-mill desktop applications. Those islands are what isolate developers from the thorny problems of simultaneous data access, deadlock, and other pitfalls of multithreading. Developers are encouraged to identify functions of their applications that would be better executed off the main thread, even if they're made up of several sequential or otherwise partially interdependent tasks. GCD makes it easy to break off the entire unit of work while maintaining the existing order and dependencies between subtasks." (source = above url)

    1. Re:Blocks and GDC by inKubus · · Score: 0, Troll

      So it's slow, but convenient, multi-threading. That's ok because the 16 core and 32 core chips will be here in 3 years.

      If you want to do something fast you're not going to rely on a big, general OS library to queue up threads... Photoshop, for instance, will not be using this library. ;)

      --
      Cool! Amazing Toys.
    2. Re:Blocks and GDC by alannon · · Score: 1
      Slow multi-threading? Assuming this Wikipedia article is correct (the reference currently points to a dead document on Apple's site) queuing up a task for thread-dispatch takes only 15 instructions which seems a lot faster than spawning a new thread. In the end, though, it's still just threads, just a convenient way for developers to take advantage of them. If not with threads, how would you expect Photoshop to take advantage of multiple cores? And how do you think it creates these threads? By using one of several "big, general OS libraries" that exposes the API, such as Core Foundation (MacOSX), pthreads or Win32 each of which will just end up using an underlying kernel system call.
      As I see it, these are the advantages
      • A global thread-pool, meaning applications don't need to maintain their own, and the kernel can manage the size of it according to system resources
      • New language constructs that will encourage developers to use threads in more places, since it is now utterly painless to make a block of code execute in its own thread
      • (On OSX, at least) Kernel level acceleration for queuing up tasks

      I can think of absolutely no reason why developers writing new OSX software (OS backward compatibility aside) would not take advantage of this.

    3. Re:Blocks and GDC by BasilBrush · · Score: 1

      Who said it is slow?

      Because it makes it more likely for all cores to be used efficiently, it's a speed up vs the old methods on existing chips.

    4. Re:Blocks and GDC by Ilgaz · · Score: 1

      It seems you have been victim of a real troll, which is rare these days. Multi threading issues of OS X is more like that ''move 17MB file'' thing (which is fake). Threading issues existed in very early times, Oracle was one of the first to see it along with MySQL and it was fixed somehow.

    5. Re:Blocks and GDC by Clover_Kicker · · Score: 1

      It doesn't hurt anyone if a few really sophisticated developers roll their own really efficient threading in a few apps.

      The idea here is for every 2-bit Mac developer to have idiot-proof threading at their fingertips, so even trivial apps are multithreaded, which means less time with your CPU meter stuck at 50% or 25% or whatever.

    6. Re:Blocks and GDC by inKubus · · Score: 1

      Right, that's what I was saying. I'm not trolling. This is "framework level" multi-threading for multi-core processors that's simple but dumb. So it's going to be slower than real optimized functions that do the same thing. Big, fat OS calls generically handle lots of situations, but they do it with special cases which take time to process.

      --
      Cool! Amazing Toys.
    7. Re:Blocks and GDC by Anonymous Coward · · Score: 0

      the gcd overhead is less than the overhead of spawning a new thread or forking a new process. Photoshop (like all adobe software) uses their own half-assed UI and flash shit that looks like ass everywhere, so no, they won't be using it and their software is slow.

    8. Re:Blocks and GDC by Anonymous Coward · · Score: 0

      simple but dumb.

      I would argue just the opposite - this sounds like it is sophisticated and smart. Because it knows about the current state of the whole system, it can more intelligently allocate and schedule threads among all active processes. Yes, the overhead to create a task/thread in GCD may be more (though someone above implied it's very small - I don't know), but the whole point is that the entire system will run more efficiently if everything is using this. Therefore you end up with a net speed increase.

      Regarding your earlier Photoshop comment, I would agree that Adobe won't use this technology. However, I think the reason is simply that they have to support Windows (the majority of their customer base), so any Apple-only technology is out (with the obvious exception of gui stuff).

    9. Re:Blocks and GDC by Anonymous Coward · · Score: 0

      You are correct except for one detail: today's headline is that libdispatch is now open-source, and is therefore no longer Apple-only technology. The implementation of blocks in LLVM's compiler-rt has been available or a while. This largely removes the objection you mentioned.

    10. Re:Blocks and GDC by m95lah · · Score: 1

      I think 16 or 32 is counting low.

      Consider Larrabee (yes, it is a GPU, but it runs the x86 instruction set, so it'll certainly not be long until it gets used by regular apps for other stuff as well), it is assumed that it will have 32 cores in its first version, and each will have four hardware threads. Presto, 128 hw threads! And this will likely be available in about a year!
      How long until this sort of tech goes into the general cpus? I'd say less than 3 years.

      All developers worth their salt should start thinking about concurrency, and how they're going to make use of these multitudes of low-powered cores. I can recommend Herb Sutters course in "Effective Concurrency" for those who are interested.

      http://en.wikipedia.org/wiki/Larrabee_(GPU)
      http://gotw.ca/

  8. This does not help, Apple. by Anonymous Coward · · Score: 1, Interesting

    Apple has a long tradition to make things its own way, not always in the cleanest way under the hood. This does not always help, and sometimes it just adds to the confusion. Why parallel programming has to be tied to a kernel change and to a language spec change, when a good library (OpenMP, anyone?, but I'm sure there are others) will suffice... Good support for OpenMP or any of the existing shared memory parallel programming libraries would have been much cleaner and portable.

    Disclaimer: I use/program/work with an Intel Macbook Pro.

    1. Re:This does not help, Apple. by cbreak · · Score: 2, Informative

      Abstraction is the main theme in progression in programming. Blocks (Language change) and the rest of the package provide such an abstracted view.

      GCD also does not need kernel changes as written in the sumary.

    2. Re:This does not help, Apple. by lisaparratt · · Score: 2, Insightful

      My understanding of GCD is that it makes parallel programming and, importantly, interacting with the UI, pretty damned easy.

      And despite that, if the only thing you can think of to do with Blocks is threading, then you seriously need to get back to learning your CompSci. Resource Allocation Is Invocation becomes a load more practical, and that alone would mark a major shift between C code that's mostly resource and error management overhead and code that actually does something.

    3. Re:This does not help, Apple. by Anonymous Coward · · Score: 0

      > GCD also does not need kernel changes as written in the sumary.

      Without a kernel implementation, GCD is crippled.

    4. Re:This does not help, Apple. by lurch_mojoff · · Score: 1

      Why parallel programming has to be tied to a kernel change and to a language spec change, when a good library (OpenMP, anyone?, but I'm sure there are others) will suffice...

      GCD is not tied to the kernel and a parallel programing library (like OpenMP) won't suffice, because none of the ones that I've seen so far is as easy to use as GCD backed blocks.

      Good support for OpenMP or any of the existing shared memory parallel programming libraries would have been much cleaner and portable.

      GCD is pretty clean and, since both libdispatch and llvm are open source (and under BSD-like licenses), it and the code written against it are infinitely portable.

    5. Re:This does not help, Apple. by ThePhilips · · Score: 1

      Apple has a long tradition to make things its own way, not always in the cleanest way under the hood.

      I grew out of being purist and now I can reply you: to keep the sh1t in one place.

      Otherwise you can go Linux way: keep tech under the hood clean, but as collateral force every program to swallow some of the sh1t and pass it on to end user.

      And we all know that in the end the approach doesn't work. Struggles of Linux on desktop is the best evidence of that.

      --
      All hope abandon ye who enter here.
    6. Re:This does not help, Apple. by Anonymous Coward · · Score: 2, Interesting

      Why parallel programming has to be tied to a kernel change and to a language spec change, when a good library (OpenMP, anyone?, but I'm sure there are others) will suffice...

      OpenMP requires "language changes" - it introduces new compiler keywords, and the compiler must support it, it's not "a library".

      Get yourself a clue.

    7. Re:This does not help, Apple. by am+2k · · Score: 2, Informative

      Note that OpenMP is supported in Mac OS X, and has been for a while. It's just not as user-friendly, you have to think a lot more about variable scope and dependencies.

      With Grand Central Dispatch, you basically only have to flip a boolean flag and it's running in parallel (in ObjC at least).

    8. Re:This does not help, Apple. by lurch_mojoff · · Score: 1

      I'd say crippled is too strong of a word here. Form the libdispatch project main page, linked in the blurb above:

      While kernel support provides many performance optimizations on Mac OS X, it is not strictly required for portability to other platforms.

    9. Re:This does not help, Apple. by jedidiah · · Score: 1

      > And we all know that in the end the approach doesn't work. Struggles of Linux on desktop is the best evidence of that.

      No it isn't really.

      The Linux desktop as it is today didn't exist in 1997. It hadn't even been started yet.

      On the other hand, Windows and MacOS had over 10 years of product releases. Despite the fact that MacOS was VASTLY SUPERIOR in by any metric except for "price" and "compatability" it continued to have it's ass handed to it time and time again in the market by MS-DOS of all things.

      "Better engineering" in Cupertino isn't all it's cracked up to be.

      --
      A Pirate and a Puritan look the same on a balance sheet.
    10. Re:This does not help, Apple. by truthsearch · · Score: 1

      If everyone did everything one way there would never be any progress. Apple uses many open standards and open source code, while making their own alternatives when they need something better. Nothing wrong with that.

    11. Re:This does not help, Apple. by Spaham · · Score: 1

      it and the code written against it are infinitely portable.

      just wait till I've finished to infinitely port it ! :)

    12. Re:This does not help, Apple. by Anonymous Coward · · Score: 0

      If you know your way on C, and have an idea of what multithreading is, you can learn OpenMP in one afternoon. And it is supported for free in gcc 4.3+ in most platforms. Why reinvent the wheel? On top of that, the changes to make your program parallel will be minimum, and it will still compile in other non-parallel compilers/platforms.

      And to the people that says that programming for GCD is easier (or more elegant, or less 'lines of code', or whatever), I tell them to go and give both of them a try before opening your mouth. GCD is for the desktop. You do not need a paradigm shift for that, or invent new language features. Just appropriate libraries and good programmers.

      This feels very much on the line of choosing ObjC over C++ as their system programming language. If you ever had to write portable code, you know how much does it gets in your way. Apple just wants its little way, as in everything else. I do like their products, but their arrogance is a pain, and will eventually catch up with them... oh.. and yes, I am using a mac..

    13. Re:This does not help, Apple. by Anonymous Coward · · Score: 0

      You seem to be confusing marketing with technology. Also what's this 10 years of product release non-sense? OS X first shipped in 2001, Linux was first released in 1991... so Linux had 10 years on OS X, not the other way around. Both of these had roots in Unix (though Linux followed the GNU path and Apple followed the BSD path).

    14. Re:This does not help, Apple. by itsdapead · · Score: 1

      The Linux desktop as it is today didn't exist in 1997. It hadn't even been started yet.

      Last time I looked, the Linux desktop was still built on the X Window System, which dates back to the 1980s.

      Of course, X is a network-enabled graphics library, not a desktop. Which is probably part of the problem...

      On the other hand, Windows and MacOS had over 10 years of product releases

      Except that both Apple and MS completely junked their original desktop operating systems circa 2000. Win2k is not a development of Win95, Mac OS X is not a development of Mac OS 9.

      Despite the fact that MacOS was VASTLY SUPERIOR in by any metric except for "price" and "compatability" it continued to have it's ass handed to it time and time again in the market by MS-DOS of all things.

      That didn't have anything to do with even price or compatibility, let alone any technical considerations. MS-DOS simply managed to inherit the "nobody ever got fired for buying IBM" meme and ensure that no manager worth his pointy-hair would contemplate buying anything else (I remember trying to argue for solutions which were cheaper and more compatible than PC/DOS and finding myself pissing in the wind). The reality distortion field must have been rated at least 37.5 kiloJobs - even respectable journalists were writing glowing reviews of the "meh" piece of mediocre crap that was the original IBM PC. There were better MS-DOS (non-PC compatible) machines for crying-out loud. Apple survived by creating a niche in Graphics/DTP in which DOS couldn't even pretend to compete.

      --
      In a survey of 100 programmers, 111111 thought that duck-typing was a good idea.
    15. Re:This does not help, Apple. by hattig · · Score: 1

      C'mon, KDE was started by then, because I remember running version 1 in 1998. I believe 1998 was the year of Linux on the Desktop even.

      There is nothing but good in getting a useful library, even as a CHOICE, out in the open source world for use by other projects. It sounds genuinely useful for small to medium sized projects, and big projects will implement something themselves as they already have. Indeed I bet some big projects will switch to use this, if they can, especially if the library is available on other platforms for their use.

    16. Re:This does not help, Apple. by 93+Escort+Wagon · · Score: 2, Insightful

      Good support for OpenMP or any of the existing shared memory parallel programming libraries would have been much cleaner and portable.

      This seems to be one of the common complaints in this discussion ("why not contribute to an existing project instead?") and others involving Apple's open-source participation, and certainly it has merit. But open-source developers write their own more-or-less redundant tools all the time with no better justification than "I didn't like how tool X handled the specific case Y, so I wrote my own tool from scratch" - SourceForge is littered with them. So (I'm responding generally, not to the parent) I don't see why Apple seems to be given an inordinate amount of grief over this - they didn't like how the existing stuff worked, so they wrote their own. Same thing they've done with launchd for that matter. Or moving away (somewhat) from gcc.

      Also, having written their own tool, they released it under a license they preferred. To borrow a phrase frequently used in defense of the GPL - if you don't like the license, you're free to not use the tool and/or go write your own.

      --
      #DeleteChrome
    17. Re:This does not help, Apple. by shutdown+-p+now · · Score: 1

      OpenMP is lower-level compared to GCD.

    18. Re:This does not help, Apple. by shutdown+-p+now · · Score: 1

      Blocks, which are needed to use GCD in a reasonably convenient way, are also a language extension.

    19. Re:This does not help, Apple. by Anonymous Coward · · Score: 0

      With Grand Central Dispatch, you basically only have to flip a boolean flag and it's running in parallel (in ObjC at least).

      And that's the other big difference between GCD and OpenMP. OpenMP is designed to work with C and Fortran (although gcc might allow it's use with ObjC and C++ too). Apple's GCD, on the other hand, is really designed with ObjC in mind — there is no Fortran interface, so for us scientific number-crunchers, that's a big check mark in the OpenMP column.

      -JS

    20. Re:This does not help, Apple. by lordholm · · Score: 1

      Firstly ObjC is not apples system programming language. It is however their application programming language which is a different thing.

      I have tried both OpenMP and GCD, and I have to agree that GCD in combination with blocks is a lot more elegant. It actually makes concurrency dead simple.

      OpenMP was the last time I checked based on pragmas for specifying concurrency in various places like a for-loop for example. GCD is based on closures and thread pools and is just so much nicer to hack with. One nice thing with GCD is that you can register event handlers acting on various system events, one I tried out was a mini server that creates a listening block that is triggered as soon as there is data in the input socket, GCD is quite flexible. It's main issue in the beginning was that libdispatch was only on Snow Leopard, now it is open source, and for my part that means that the code is actually portable (as long as you stick with clang or llvm-gcc for the compiler) and I might actually end up writing code using this.

      It is hardly reinventing the wheel (OMP is not equivalent to GCD, that is like saying that Python is reinventing the wheel called C (well they are both procedural programming languages after all)), one of the main problems with todays software is that writing concurrent apps is quite hard, yes OpenMP is nice, but it is mostly tailored to scientific code, and it cannot handle events in the way i mentioned for example.

      --
      "Civis Europaeus sum!"
    21. Re:This does not help, Apple. by Me!+Me!+42 · · Score: 1

      OpenMP is great but GCD is more flexible and goes a step further (despite the fact that the code looks very similar.)
      GCD ends up being faster since it's system aware it can adjust for the actual resources available rather than depending on the developers best guess. GCD gains by avoiding over-producing threads which leads to wasteful thread swapping that is inevitable when trying to make optimal use of OpenMP.
      Looks like a cool and sensible implementation to me.

      --
      -- My apologies if the above facts contain any opinions, or vice versa! --
    22. Re:This does not help, Apple. by Ant+P. · · Score: 1

      It works fine in C too, actually.

    23. Re:This does not help, Apple. by Anonymous Coward · · Score: 0

      GCD also works with plain old function pointers.

    24. Re:This does not help, Apple. by Anonymous Coward · · Score: 0

      NeXTstep was released in 1989, so MacOS X really had a 2-year jump on linux.

    25. Re:This does not help, Apple. by shutdown+-p+now · · Score: 1

      It does, but less trivial things are very inconvenient when you need to hand-code the closures - as with any other library that heavily relies on first-class functions.

    26. Re:This does not help, Apple. by Anonymous Coward · · Score: 0

      you surely mean
      http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization

      i post anon to keep my bad karma

  9. GPL violation? by Anonymous Coward · · Score: 0, Insightful

    Why would Apple suddenly open-source a major feature of their new OS? Did they get busted violating the GPL? It doesn't make sense that the most closed-source draconian control-freak vendor of all would suddenly open-source major parts of their OS without some legal Sword of Damocles hanging over their head. What aren't we being told here? Whose code did they get caught stealing?

    Someone somewhere owes the community an explanation!

    1. Re:GPL violation? by Lemming+Mark · · Score: 4, Informative

      Well, I can see the logic of your concerns but Apple do actually seem to be fairly good at open sourcing infrastructure-related things. Sure they maintain a tight control on the user-facing stuff that makes Apple products distinctive - on the iPhone they even maintain a tight control on applications. But bear in mind they're working on an open source kernel, employ developers to work on the LLVM compiler (open source), open sourced an init-ish daemon (launchd) they developed, etc etc. On stuff that's "for geeks" they seem fairly enlightened wrt open source.

      It's quite surprising from a company like Apple but the fact that they manage to make surprising decisions like that looks like a strong technical management team at work, to me.

    2. Re:GPL violation? by dingen · · Score: 1

      Why is it so remarkable to you that Apple open sources one of their technologies? They already have several open sources projects which they use in their software, such as Darwin and Webkit. They also use lots of 3rd party open source technologies in their software. I don't think they're doing all of this because they're somehow violating licenses, but because they just think open source isn't so bad.

      --
      Pretty good is actually pretty bad.
    3. Re:GPL violation? by UnknowingFool · · Score: 4, Insightful

      Apple has a long history of open source contributions since OS X. Apple has released parts of OS X as Darwin under a BSD license since they first released OS X. OS X was developed from OPENSTEP which came from NextStep which itself was based on BSD. The kernel itself is derived from XNU which was based on the Mach kernel. All of these components are covered by BSD licenses. From what I understand since Apple uses a lot of open source Unix programs like CUPS, etc, they do contribute to fixes and patches on a regular basis.

      --
      Well, there's spam egg sausage and spam, that's not got much spam in it.
    4. Re:GPL violation? by Anonymous Coward · · Score: 0

      Someone somewhere owes the community an explanation!

      Yes. That someone is you. That community is retards. You're making them look bad.

    5. Re:GPL violation? by Dog-Cow · · Score: 3, Insightful

      Apple actually owns CUPS now. But, yes, they still make it available under an OSS license.

    6. Re:GPL violation? by cbreak · · Score: 1

      Big parts of Mac OS X are open source, including the kernel, the compiler and some basic libraries. Now including LLVM, Clang and GCD.

    7. Re:GPL violation? by AndrewNeo · · Score: 2, Insightful

      If they were violating the GPL they probably wouldn't have released it under the Apache 2.0 license..

    8. Re:GPL violation? by je+ne+sais+quoi · · Score: 3, Informative

      Here is the list of all the open source packages apple uses. These include the kernel and CUPS (under the 10.6 tab), as well as their own modified version of other open source packages like java or gcc (under the developer tab). Contrary to a lot of a the common "apple is teh proprietary satan!!1" posts on slashdot, apple acts just like you might expect a more or less decent proprietary unix distributor to act: they open source what they can but keep closed whatever they feel is necessary to maintain a competitive advantage against Microsoft or that would infringe on hardware sales.

      P.S. As in interesting tidbit, you'll notice that clamAV is posted there as well. Hmm, makes you wonder.

      --
      Gentlemen! You can't fight in here, this is the war room!
    9. Re:GPL violation? by Anonymous Coward · · Score: 0

      Fucking idiot should stay silent when he doesn't know what the fuck he's talking about.

      Two points:

      1) Apple has been open sourcing major parts of their OS for years.

      2) How the fuck would open-sourcing something under the Apache license have anything to do with a GPL violation?

      Next time, please engage your brain before posting. And then don't post.

    10. Re:GPL violation? by onefriedrice · · Score: 1

      As a GPL advocate, the GP can't fathom why a company like Apple would willingly release code under a free license so that the community can benefit. He has been living by his apparently false belief that we need the over-complicated GPL (along with its inherent incompatibilities with other freer licenses) to force companies to give back. He's been conditioned to believe that the GPL has high value and utility in keeping code free, when in reality companies do give to non-GPL licensed free software projects like Apache PostgreSQL without being coerced.

      --
      This author takes full ownership and responsibility for the unpopular opinions outlined above.
    11. Re:GPL violation? by ceoyoyo · · Score: 2, Informative

      Don't forget they've contributed a lot to WebKit, which now seems to be used by every new browser that comes out.

    12. Re:GPL violation? by alanQuatermain · · Score: 1

      As in interesting tidbit, you'll notice that clamAV is posted there as well. Hmm, makes you wonder.

      It's used in OS X server, where it integrates with the mail service in order to filter/block emails containing known viruses.

    13. Re:GPL violation? by 99BottlesOfBeerInMyF · · Score: 3, Insightful

      It's quite surprising from a company like Apple...

      Companies are defined by what they do. If a person surprised Apple is releasing technologies as open source projects, that just means that person has an inaccurate image of what kind of company Apple is and should pay more attention to what Apple does and less to espoused, unsupported opinions from astroturfers and zealots.

    14. Re:GPL violation? by Lemming+Mark · · Score: 1

      Companies are indeed defined by what they do - the majority of what Apple does in the marketplace is provide tightly integrated "Just Works" experiences by maintaining a strong control over what they do. They also maintain intense secrecy on all their products. Do you dispute anything specific that I said?

      At the end of the day *nothing* is really unexpected on some level since there are unseen laws and logic governing basically everything that happens. But if you see a trend in behaviour from somewhere (e.g. tight control and secrecy in most of Apple's most visible things) and then that trend is apparently violated, that qualifies as "surprising" in my opinion.

    15. Re:GPL violation? by Lemming+Mark · · Score: 1

      Good point, that's actually a biggy and I shouldn't have missed that.

      At one point one of the KDE devs pointed out that, contrary to most folk's expectations, interaction between KHTML wasn't happening because Apple were - at the time - complying with the letter of the license but not really providing patches in a useful form. The KDE guy was basically saying "No, really, we're still on our own with KHTML" to uninformed commenters, rather than necessarily saying Apple was being bad.

      After that, Apple addressed these concerns and massively improved (AFAIK) their community interaction over WebKit. Pretty impressive in my view. Openness and responding effectively to criticism is not the kind of thing Apple is usually known for - but unlike some companies they do often seem to understand that OSS works better as a two way street, rather than just going "OMG free developers!".

    16. Re:GPL violation? by kamochan · · Score: 1

      ClamAV is included in OS X Server. As is tomcat, and many other bits you can find on the web page, that you can't find in your OS X desktop.

    17. Re:GPL violation? by broken_chaos · · Score: 1

      From what I've seen, Apple definitely got a good deal out of the WebKit community interaction - there's a huge number of people doing bug reporting, snapshot testing, and submitting patches as a result.

    18. Re:GPL violation? by SuperKendall · · Score: 1

      They also maintain intense secrecy on all their products. Do you dispute anything specific that I said?

      Yes - they only have intense secrecy around END PRODUCTS.

      But "product" can be thought of another way, in the various parts that make up the whole. While an end user "product" may be secretive many of the components used to make it are all as open as anything can be - BSD subsytems for the OS, Darwin for the kernel, Webkit for Safari (and used across many "secretive" apps like iTunes). GCC and now LLVM, LaunchD, and now GCD and also OpenCL (which I believe they are submitting to a standards body too).

      At the end of the day *nothing* is really unexpected on some level since there are unseen laws and logic governing basically everything that happens.

      It's not that much of a mystery. Apple either takes open source things and builds custom apps atop them, or builds custom apps atop technologies that it then open sources. It's not like we're talking about lamb entrails here folks, Apple has been openly and consistently doing this for many years now.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    19. Re:GPL violation? by Lemming+Mark · · Score: 1

      I think really we're debating over semantics at this point - my original post was trying to point out that whilst Apple is known for its secrecy and control it is pretty open on infrastructure stuff, where it makes sense for them.

      All I meant by "surprising" was that it's unusual to see a company that's known for tight integration and control but which also has another greatly contrasting. I'm not personally surprised by Apple's behaviour since it's consistent with what I've seen from them in the past. But I can see why it would be surprising to someone who had only seen the more visible retail face of Apple.

    20. Re:GPL violation? by Anonymous Coward · · Score: 0

      I believe Mac OS X Server ships with/supports using Clam AV on their mail server.

    21. Re:GPL violation? by Anonymous Coward · · Score: 0

      I dispute that they maintain "intense secrecy on all their products", because it's obviously false. They maintain intense secrecy on their unreleased products, but you may have noticed that 10.6 came out two weeks ago now.

    22. Re:GPL violation? by 99BottlesOfBeerInMyF · · Score: 1

      Companies are indeed defined by what they do - the majority of what Apple does in the marketplace is provide tightly integrated "Just Works" experiences by maintaining a strong control over what they do.

      I disagree, slightly. Apple does, indeed, use the business model of providing a polished end user experience, often limited, but easy to use for what it does. They sometimes do this by maintaining a lot of control over all the components, but not in all cases. In other cases they do this by partnering with other companies and organizations or by building a product that integrates well with the existing ecosystem. Controlling all the components is only one of their methods of implementing that business plan.

      They also maintain intense secrecy on all their products. Do you dispute anything specific that I said?

      Absolutely. Apple completely documents and voluntarily provides the source code for large portions of many of their products. That is certainly not maintaining secrecy about them. Rather, Apple is famed for being secretive about new and upcoming products that have not been released. This is for two reasons. First it allows them to make an effective marketing splash and draws interest from the press. Second, Apple makes a lot of money by innovating and by maintaining secrecy they maximize the time to market advantage they have over those who copy their innovations.

      That said, such secrecy as Apple has demonstrated has little to do with whether or not Apple releases source code to products after it comes to market. That's an action they regularly take, so to not expect them to take it, you have to be misconstruing what apple normally does.

      At the end of the day *nothing* is really unexpected on some level since there are unseen laws and logic governing basically everything that happens. But if you see a trend in behaviour from somewhere (e.g. tight control and secrecy in most of Apple's most visible things) and then that trend is apparently violated, that qualifies as "surprising" in my opinion.

      Ahh, but if you're perceiving Apple as being secretive about how their products work and about the source code it just means your perception is inaccurate. This, in turn, means you should look at your preconceptions and information sources. Apple releases the source code for the 600th or 700th project and that's a surprise? Apple releases the source to a foundational new technology they implemented in OS X? That might have been surprising when it was the original release of Darwin, or even when it was the libc and io stuff they made from scratch and gave away the source to subsequently. But come on already. They've been releasing the source to underlying technologies they add to OS X, with every release for over a decade now. Grand Central is exactly the type of technology that Apple leverages the open source model for, being as it benefits from more eyes and more contributors and the more people that use it the better software developers will get at making applications multiprocess well on OS X. It should be no surprise at all to someone with an accurate perception of how Apple operates as a fairly good, mixed OSS community player, that understands OSS and regularly leverages it for their products.

      Frankly, I think your perception of Apple has to be pretty messed up to be surprised by Apple releasing the source to GCD. The reason this is news is because of the idea that other OS's might be able to integrate it and because it is potentially so useful. Most of the time what Apple releases isn't even news. Heck, they released a dozen packages for their underlying security framework in case anyone wants to make use of their version of sandboxing.

      I guess the long and short of the matter is, if you're surprised by this, do you just have an anti-Apple bias and why do you have that?

    23. Re:GPL violation? by Lemming+Mark · · Score: 1

      You're misinterpreting what I originally meant in a fairly extreme way. Did you look at the context I was commenting in?

      To be fair, perhaps I could have phrased it better. When I said "products" I should probably have said "retail products" to disambiguate from stuff (like open source code) that they produce but don't market to consumers.

      I used "surprising" in the sense that "It's unusual to see a company that has both extreme secrecy and enlightened openness". "Surprising" in general, then, as opposed to surprising for a fully informed observer. I wasn't surprised personally, since I've been following Apple's open source activity for years, including quite obscure stuff (for instance, I understand they sponsored some Linux work back in the day). However, the person I replied to *was* personally surprised - I was trying to explain that whilst I understood his surprise, it was not indicative of anything fishy.

      If you reread my post, you'll see that I commented that Apple do open source quite a lot of infrastructure stuff and that I believe that maintaining those seemingly contradictory stances is an indication of strong management. I was replying to somebody who was suspicious of the motives of Apple in this - and pointing out that although it might look odd it's actually quite normal behaviour for them.

      I was aiming to be evenhanded and was, after all, defending them against accusations of copyright infringement. If a defense of the company qualifies as anti-Apple, then I'd hate to meet an Apple hater!

  10. Use Cilk by pikine · · Score: 0

    Just looked at libdispatch source code. It is apparently very Mac OS X specific, and will take a lot of work to be ported cross platform. The queue implementation also looks like it imposes a lot of overhead, so it is not very useful for parallelizing short-running "blocks" of code.

    Why not use something like Cilk which has proven its salt? The only caveat of Cilk is that it requires any parallel code to be compiled with the Cilk compiler (which will generate C code), and unless you're willing to kickstart the Cilk runtime manually, any caller of the parallel code needs to be compiled with Cilk too, which includes main(). The technical reason is Cilk does a continuation passing style transformation (requiring a different calling convention) which allows a function caller to be stolen by the work-stealing scheduler while the function waits for the callee to finish, allowing the critical path to focus on work instead of manipulating the task queue. The result is a highly efficient and scalable parallel execution runtime, the best I've seen.

    --
    I once had a signature.
    1. Re:Use Cilk by PacoCheezdom · · Score: 5, Insightful

      You don't think that libdispatch will be very genial to widespread usage, as it has a lot of OS-specific calls, which is an understandable position to take. But as an alternative you offer something whose "only caveat" is that it needs an entirely different compiler to build. A compiler whose most recent activity dates from two years ago.

      ... How is that a superior alternative?

    2. Re:Use Cilk by Dog-Cow · · Score: 4, Informative

      GCD is designed for small, short-running blocks of code. Read the Ars article on Snow Leopard for examples. Naturally, it will also handle longer-running threads gracefully.

      Whoever modded you informative is as ignorant as you.

    3. Re:Use Cilk by Rogerborg · · Score: 1

      The usual way: anything that I know how to use is obviously far superior to everything that you know how to use.

      --
      If you were blocking sigs, you wouldn't have to read this.
    4. Re:Use Cilk by AndrewNeo · · Score: 1

      I wouldn't be surprised if a lot of the way it was designed is to work with Objective-C, due to it being OS X's primary language.

    5. Re:Use Cilk by samkass · · Score: 4, Informative

      No, GDC is purely a "C with block extensions" API. The blocks are essentially anonymous methods you can pass directly in to functions. It's integrated at a much lower level than Objective-C, which is only used for the higher-level application framework in MacOS.

      Apple open-sourced the GDC API with this announcement, block extensions to C with LLVM implementation last week, and the OS support necessary as part of the xnu kernel Darwin release for 10.6.

      --
      E pluribus unum
    6. Re:Use Cilk by Anonymous Coward · · Score: 0, Troll

      Maybe someone who already read can post an illustrative example? I'm bitter and cynical and don't care to chase after every ball a marketing dweeb throws my way, and am simply curious where this fits in the constellation of parallelism that dates back 30 years or more.

      Who identifies the work units which can run in parallel? A compiler or the application programmer?

      Who identifies the decomposition of the application data model into the work units and their state sharing and synchronization? A compiler or the application programmer?

      Who identifies the strategy for gathering work unit results back into the sequentially consistent form required after they all complete? A compiler or the application programmer?

      If the answer to all of these is the programmer, how does this really differ from the idiomatic POSIX threads application which uses user direction and/or trivial system probes to choose a thread count N appropriate to the system, then fires off N threads running the same worker function (block), then uses normal synchronization to wait for the threads to complete?

    7. Re:Use Cilk by gabebear · · Score: 1
      You can evidently queue several small parallel blocks together like so:

      #define COUNT 128
      dispatch_queue_t q_default;
      q_default = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
      __block double result[COUNT];
      dispatch_apply(COUNT, q_default, ^(size_t i){
      /* indent */ result[i] = complex_calculation(i);
      });
      double sum = 0;
      for (int i=0; i < COUNT; i++) sum += result[i];

      And even use an async accumulator across them

      #define COUNT 128
      __block double sum = 0;
      dispatch_queue_t q_sum = dispatch_queue_create("com.example.sum", NULL);
      dispatch_apply(COUNT, q_default, ^(size_t i){
      /* indent */ double x = complex_calculation(i);
      /* indent */ dispatch_async(q_sum, ^{ sum += x; });
      });
      dispatch_release(q_sum);

      http://developer.apple.com/mac/articles/cocoa/introblocksgcd.html

      I'm going to play with this later today. Even if the current version's performance isn't awesome, it lays the foundation for some really nice boosts by allowing you to express what you want to the compiler better.

    8. Re:Use Cilk by larry+bagina · · Score: 1

      Blocks themselves are Objective C Objects* (which is to say the first element in the structure is a pointer to their Class). That's mostly a convenience, much like how CoreFoundation are toll-free bridged as NSObjects.

      * Most Objective C Objects (other than string constants) are created on the heap; blocks are initially created on the stack and only moved to the heap if necessary.

      --
      Do you even lift?

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

    9. Re:Use Cilk by gabebear · · Score: 1

      Who identifies the work units which can run in parallel? A compiler or the application programmer? Who identifies the decomposition of the application data model into the work units and their state sharing and synchronization? A compiler or the application programmer? Who identifies the strategy for gathering work unit results back into the sequentially consistent form required after they all complete? A compiler or the application programmer?

      It seems the programmer identifies the work units(called "object blocks") and has explicit control over synchronization, but gives up control over scheduling those tasks. A decent doc at http://developer.apple.com/mac/articles/cocoa/introblocksgcd.html

      The new thing here seems to be the system-wide scheduler for these work blocks. Rather than just having the OS manage threads, this allows the OS to schedule short-lived tasks on whatever resources it has. I don't know if there has ever been system-wide management of light-wieght threads before... or if it is a good idea.

    10. Re:Use Cilk by Ant+P. · · Score: 1

      What does the GNU D Compiler have to do with any of this?

    11. Re:Use Cilk by Anonymous Coward · · Score: 0

      "..., as it has a lot of OS-specific calls" is a rather unsubstantiated statement to make; have you looked at the code? Aside from using kqueues for event delivery, which have been a "BSD standard" for some time now, the other OS-specific mechanisms are for optimization only; GCD can be hosted on top of standard pthreads, and you can devise (or choose not to) any throttling mechanism on top of that, that you like. Subscribe to the libdispatch-dev mailing list if you want to follow the progress of folks who are far more aware of the portability concerns than you appear to be.

      As to clang, it's far more active than "2 years ago". What metrics are you using to determine that? Blocks certainly didn't come along 2 years ago, for example, and yet it's clearly visible work going on in clang. That post wasn't insightful, it was FUD!

    12. Re:Use Cilk by node+3 · · Score: 1

      The queue implementation also looks like it imposes a lot of overhead, so it is not very useful for parallelizing short-running "blocks" of code.

      Actually, it's extremely good at parallelizing short-running blocks of code.

      Unless your program is going to run on a very specific and unchanging computer configuration with all other tasks known and well-defined, GCD will pretty much *always* do a better job and handling and prioritizing threads.

      Any performance lost in overhead is regained many times over in threads not bogging down the system. It's a bit similar to comparing cooperative and preemptive multi-tasking. With preemptive, there is system overhead in it having to manage all the various processes, but cooperative is so inefficient that the overhead is miniscule compared to the gains in the vast majority of scenarios.

    13. Re:Use Cilk by Anonymous Coward · · Score: 0

      He's talking about the last release of the Cilk compiler.

    14. Re:Use Cilk by Bluesman · · Score: 1

      Why do you think cooperative threads inefficient? Is it because people use them inefficiently?

      Cooperative threads, when used correctly, are more efficient than pre-emptive because with pre-emptive, you have to save and restore all state to context switch (kernel preempts a process, and doesn't know which registers are in use, so has to save them all). With cooperative, you can context switch at function boundaries and not have to save the callee-save registers.

      --
      If moderation could change anything, it would be illegal.
    15. Re:Use Cilk by David+Greene · · Score: 1

      Wow, this is tremendously ugly. Futures seem a better way of doing this:


      #define COUNT 128
      double sum = 0;
      future double x[COUNT];

      for(i = 0; i < COUNT; ++i) x[i] = complex_calculation(i)

      for (i = 0; i < COUNT; ++i) sum += x[i];

      The async accumulator thing looks confusing to me. With futures the accumulation becomes part of the spawned task.

      --

    16. Re:Use Cilk by node+3 · · Score: 3, Insightful

      That's exactly my point. With cooperative multitasking, if you know everything that's going on, it can be more efficient than preemptive multitasking. Just like manually managing your threads can be more efficient than something like GCD.

      At the most fundamental level, cooperative is more efficient (if well programmed), just as manually managing threads (if well programmed) is more efficient.

      It's that "if well programmed" that's the killer. If your environment is completely known, *and* you are skilled, you have the potential to do a better job by hand. But in the real world, were your software is going to run on all sorts of computers with all sorts of different software and processing capabilities, you can't fine tune your program, so letting the system handle it works better.

      Looking at it differently, with cooperative multitasking or manually controlling threads, *if* you have complete knowledge of the system *and* you are sufficiently skilled, you can approach 100% efficiency. With cooperative multitasking, or thread management similar to GCD, you might reach only 90% efficiency. But if you have to build a cooperative multitasking or manually manages threads in a program, that is going to run on all sorts of computers, you may only manage perhaps an overall average 70% efficiency.

      And the fact that you can get that 90% efficiency with much less effort than you have to put in to get maybe around 70% (or whatever) efficiency, the benefits here are obvious.

    17. Re:Use Cilk by pikine · · Score: 0

      By your standard, Shakespeare is so old that his work cannot compare to the gibberish of an infant that was born yesterday.

      Actually the recent activities are done by a spin-off company called CilkArts. And the lack of public activity does not mean the product is not good. It simply means it has matured and did not require much improvement to be made. And how does using a different compiler ever stopped people from being productive? Apple is making you use its own fork of the GCC compiler.

      --
      I once had a signature.
    18. Re:Use Cilk by pikine · · Score: 1

      Obviously you have no respect for prior research done by respectable scholars, and you think everything under the sun (made by Apple) is new.

      --
      I once had a signature.
    19. Re:Use Cilk by pikine · · Score: 1

      Apparently in the example, it is neater to show short code as opposed to long code, but it doesn't mean it is designed to run short code.

      --
      I once had a signature.
    20. Re:Use Cilk by drerwk · · Score: 1

      Is the Cilk runtime available for OS X? If not then why consider it on OS X?

    21. Re:Use Cilk by ToasterMonkey · · Score: 1

      Don't be a sore loser, nobody said it was a new concept. I did call you a loser though, chew on that.

    22. Re:Use Cilk by Bluesman · · Score: 1

      Right, that's clearer now.

      But consider this: you don't have to know everything that's going on in order for cooperative threads to work, as long as none of the threads block (non-blocking i/o) and the compiler enforces a yield() every so often. This can all be part of the libraries and compiler you use.

      It wouldn't help spread the load across multiple CPU's, but I think cooperative threading is unfairly maligned :-)

      --
      If moderation could change anything, it would be illegal.
    23. Re:Use Cilk by gabebear · · Score: 1

      The async accumulator is adding the values into the sum as they are computed rather than waiting for them to complete in order like they do in my first example and your future example. This means you don't have to have an array and only have to have one block on the main thread for the sum, rather than 128 blocks for each value in the array. You need an upvalue to do this, and it seems most future implementations don't have them because it makes the syntax hard to read.

    24. Re:Use Cilk by gabebear · · Score: 1
      Oops, the first GCD and future example aren't really doing the same thing.
      • The first GCD example
        • creates 128 tasks
        • blocks until they all return on the main thread
        • adds the numbers on the main thread
      • The future example
        • creates 128 tasks
        • Blocks on the main thread for each task individually in the order they were queued and adds them.
      • The second GCD example
        • creates 128 tasks
          • each tasks adds it's value to the sum before it ends
        • blocks on the main thread until all tasks are done.

      Since we are just adding the complex calculations together, the first GCD and future examples are probably pretty much tied on speed. GCD only has one block on the main thread, where the future example gets to add numbers as they come in. The future example would take a penalty for continually waking the main thread just to add a number.

    25. Re:Use Cilk by iluvcapra · · Score: 1

      Do futures explicitly spawn tasks, or is it just lazy evaluation?

      --
      Don't blame me, I voted for Baltar.
    26. Re:Use Cilk by David+Greene · · Score: 1

      All you need with futures is an atomic operation.

      Granted, this is a simple case but to do anything more complex would likely require explicit synchronization for any mechanism.

      Ultimately we're talking about syntax and readability here and compiler-generated complexity always trumps user-written complexity.

      --

    27. Re:Use Cilk by David+Greene · · Score: 1

      Yes, they spawn tasks. The idea of futures is to add some syntactic sugar and let the compiler generate the code to spawn the tasks and do the waiting on the results.

      --

    28. Re:Use Cilk by iluvcapra · · Score: 1

      These are hard to read about, I'm having some trouble finding links. Could you post one or two here?

      --
      Don't blame me, I voted for Baltar.
    29. Re:Use Cilk by badkarmadayaccount · · Score: 1

      The native compiler has all the needed data, and can be as skilled as you make it.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    30. Re:Use Cilk by David+Greene · · Score: 1

      Wikipedia has an ok article here. It has a link to the C++0x standard library implementation of futures which is somewhat limited. It has many of the same problems as the blocks concept - namely, it requires too much programmer interaction. To be done properly, futures should really be understood by the compiler so it can generate all the boilerplate.

      I'm most familiar with the Cray XMT implementation of futures as described here. To briefly summarize, a future is a variable linked to the output of some asynchronous operation, usually a function call. When the future's value is set, a thread is spawned to process some task that produces the right-hand side of the future's assignment statement. Later on, when the future is actually used, there is a compiler-generated synchronization point. If the task is complete the parent thread just continues on as normal. If the task is not ready, the parent thread waits at the point of the future's use until the value becomes available. The future's thread can come from anywhere: a thread pool, a new spawn, etc.

      So essentially futures are a natural way to express the concept of some side task producing a value needed "sometime later." The XMT has special hardware to assist in the efficient processing of threads and futures but one can implement futures on any machine that provides a threading model. It's a very nice abstraction that allows the programmer to get out from under the gory details and concentrate on the problem being solved.

      --

  11. GCD -vs- OpenMP by MobyDisk · · Score: 3, Informative

    It looks like GCD is very similar to OpenMP. I am always biased toward using an open standard, when possible. Since many compiler vendors support OpenMP, why didn't apple just implement that for Objective-C, instead of creating their own threading solution? Judging from the examples, GCD looks much cleaner and simpler. But that often comes with a price.

    1. Re:GCD -vs- OpenMP by Anonymous Coward · · Score: 0

      OpenMP is dirt simple to use. If you want 'elegance', implement is att as function calls instead of pragmas. But leave the programming language the f*ck alone!

    2. Re:GCD -vs- OpenMP by gnasher719 · · Score: 1

      It looks like GCD is very similar to OpenMP.

      Who many lines in OpenMP to implement something like "do this task in a background thread at low priority, and when it's done, do that task in the UI thread"? In GCD it is two lines.

    3. Re:GCD -vs- OpenMP by Nicky+G · · Score: 1

      Doesn't "dirtier and more complex" also tend to come with a price?

    4. Re:GCD -vs- OpenMP by thefear · · Score: 1

      Further, why did Apple invent a new syntax for 'Blocks' instead of using the one already proposed for C++0x. It will make things overly complex if someone wants to use GCD with the new C++ standard, or create portability issues...

      IMO, developers are better off using OpenMP which doesn't require non-standard compiler extensions and is supported by more vendors.

      --
      :(
    5. Re:GCD -vs- OpenMP by jonesy16 · · Score: 5, Informative

      GCD and OpenMP have very little in common. OpenMP is a language extension. It requires the programmer to understand what environment their program is going to run in, what variables can be shared and how, etc. GCD merely asks you to identify blocks of code that are independent and it handles parsing them out to threads, variable replication, etc. It's the difference between providing detailed blueprints of a car (the OpenMP way) and just saying "I want a car" (the GCD way). You can *almost* think of GCD as a user-friendly frontend for OpenMP.

    6. Re:GCD -vs- OpenMP by cbreak · · Score: 1

      Apple's main language of choice for application development is not C++ but Objective-C. Objective-C is closely related to C, so putting the changes into C makes sense.

    7. Re:GCD -vs- OpenMP by ceoyoyo · · Score: 2, Insightful

      "Judging from the examples, GCD looks much cleaner and simpler. But that often comes with a price."

      I think you answered your own question. Apple is kind of fanatical for cleaner and simpler and not just in their user interfaces. It's nice. Apple APIs are some of the best I've ever used.

    8. Re:GCD -vs- OpenMP by Anonymous Coward · · Score: 0

      I think it's 3 lines. 1) do the first task, 2) wait, 3) do the second.

    9. Re:GCD -vs- OpenMP by 0xdeadbeef · · Score: 1

      Because then the stupid decision to use square brackets to simplify the parsing of Smalltalk syntax in C code would bite them on the ass.

    10. Re:GCD -vs- OpenMP by gabebear · · Score: 1

      What's wrong with square brackets? At least ObjC was designed to be a superset of C instead of a bastard language. I prefer ObjC over C++, but regularly mix them within projects. If C++0x ever becomes a standard, then it will be interesting to see how Apple deals with it in Objective-C++.

      Should it still be named C++0x? The final draft is slated for 2010 and it isn't going to be published until 2011.

    11. Re:GCD -vs- OpenMP by slyborg · · Score: 1

      > GCD looks much cleaner and simpler

      You answered your own question. My prediction : in six months there will be more GCD apps than all the OpenMP apps that have ever and will ever be written.

    12. Re:GCD -vs- OpenMP by Anonymous Coward · · Score: 0

      plus GCD is NOT Obj-C/Cocoa specific. a lot of people are missing that for some reason.

    13. Re:GCD -vs- OpenMP by dkf · · Score: 1

      Should it still be named C++0x? The final draft is slated for 2010 and it isn't going to be published until 2011.

      Sure. "C++0xa" and "C++0xb" are both perfectly acceptable...

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    14. Re:GCD -vs- OpenMP by dkf · · Score: 1

      Further, why did Apple invent a new syntax for 'Blocks' instead of using the one already proposed for C++0x.

      Because Apple (largely) don't use C++ at all, and so don't feel any need to follow what's going on there. (And "[&]" as a syntactic element for C++'s lambdas? Ick. Is that really so, or did my google-fu lead me astray?)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
  12. Re:Uh oh by Anonymous Coward · · Score: 0

    Not. Invented. Here.

  13. Re:...what is it? Check the apple web site... by klubar · · Score: 0

    You should just check the apple web site.

    Yesterdays top news in /. was how wonderful and easy-to-use the Apple web site was. If you can't find the answer, including full documentation on the site, you don't need to worry your pretty little haad about it. We're Apple, marketing (and really clever naming) rules.

    See below for marketing jargon speak:

    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.

  14. Not Invented at Apple by Anonymous Coward · · Score: 0, Troll

    OpenMP was not invented by Apple, and cannot be used as a lever to undermine gcc.

  15. Re:Kamikaze development by Anonymous Coward · · Score: 1, Insightful

    no need for kernel support
    open source implementation

    yeah. sounds a helluvalot like vendor lock-in to me

  16. Re:Uh oh by jedidiah · · Score: 0

    More importantly... "why bother?".

    It has a very "big sounding" name for what it is.

    --
    A Pirate and a Puritan look the same on a balance sheet.
  17. Re:...what is it? Check the apple web site... by jedidiah · · Score: 0

    Thread scheduling is already handled by the operating system. This is OS 101 stuff from the 80s. What ELSE does GCD add?

    My multi-threaded apps can already monopolize every CPU on my
    box whether it is a 4 core desktop or a 64 core server. Been
    that way for a LONG time.

    --
    A Pirate and a Puritan look the same on a balance sheet.
  18. Re:Kamikaze development by cbreak · · Score: 1

    Locked into open source software? I can think of worse things.

  19. Re:Kamikaze development by TomorrowPlusX · · Score: 1

    Absolutely true, but I want to point out that Apple's just trying to make simple things easy -- they're not trying to say that they've finally solved truly capital-h Hard concurrency problems.

    --

    lorem ipsum, dolor sit amet
  20. Re:Kamikaze development by am+2k · · Score: 1

    There is no tech that can help you with that. Maybe Apple should solve the solvable problems first (making parallelizing easy) before tackling the unsolvable ones?

  21. Google by Gary+W.+Longsine · · Score: 1

    What you meant to say was, "Everyone who reads Slashdot isn't an internet weeny, and has no idea how to find out what a technology of which they haven't heard before might be, other than imploring (counterproductively with a snide remark) to be spoon fed by other participants in the discussion." The answer is the wonderful invention, Google. You can type a word or phrase, like "Grand Central Dispatch", and Google will present you with links to document which discuss it. Oftentimes, one of those documents might appear at the web site of an online community encyclopedia, known as Wikipedia, which not only describes the thing in question, but also frequently provides convenient links to additional information.

    --
    If you mod me down, I shall become more powerful than you could possibly imagine.
  22. Wait, WHAT?! by Anonymous Coward · · Score: 1, Informative

    You and I must not be reading the same code.

    libdispatch constantly references mach throughout, which is unique to OS X and would take ages to #ifdef out completely. It also makes use of features only available in GCC 4.2.x or later, which means that many older platforms are out in the cold. It also makes a ton of platform assumptions (though luckily many of these are #define'd, so they can be redefined for other platforms later, however there's plenty that isn't, and is coded specifically for Intel platform performance). Furthermore, it codes in some really weird Apple-specific things (like label names for the priority queue levels, #ifdef's for Cocoa support, other very strange code, not clean in anyone's definition).

    With some significant work by an interested party, it could be made portable, but Apple didn't Open Source it with the idea that it'd immediately build on non-x86, Linux, or Windows (and in fact, it might be ages before it builds on the latter, using pthreads and functions like sysctlbyname(3) throughout). It could be portable... some day. But as it stands it's not. At all.

  23. Re:...what is it? Check the apple web site... by Penguin+Follower · · Score: 4, Interesting

    Once developers start using GCD for their applications, you'll start noticing significant improvements in performance.

    Shoot, I already noticed the difference on my 2.5 yr old Mac Pro (1.1). First boot on 10.6 and I was like "wow, feels like a new machine again". All of the bundled apps have been recompiled (64 bit) and cleaned up (and apparently take advantage of GCD everywhere possible). I really didn't think I would see that much of a difference with 10.6 and really only upgraded because I could for $29 (I mean at that price, why not right?) I am very happy with my $29 purchase thus far. I've only had to work through a couple app incompatibilities (and as I have been able to work around them just fine, I am happy.) This is of course just my experience thus far with 10.6. I have no hard benchmark numbers for you. But I noticed right away the smoothness it brought to my older Mac Pro. And it was an easier upgrade than going from 10.4 --> 10.5.

  24. Re:Kamikaze development by Dog-Cow · · Score: 5, Insightful

    You are posting in a thread about the fact that Apple made their implementation open source and you are claiming vendor lock-in?

    Are you one of those rabid Apple-haters we see so often around here? Or are you just amazingly stupid?

  25. Re:Uh oh by Anonymous Coward · · Score: 1, Informative

    I'd say adding anonymous functions to C is more than just 'big sounding'.

  26. You should have been Funny, not Flamebait by Anonymous Coward · · Score: 0

    Yup.

  27. Erlang Anyone? Anyone? by mpapet · · Score: 1

    I know the C-like language geniuses won't jump on Erlang immediately, but the multi-core support is awesome. I'm pretty sure there's a port for every platform too.

    --
    http://www.maxineudall.com/2010/02/should-economists-be-sued-for-malpractice.html
  28. Now, libxgrid... by 0100010001010011 · · Score: 1

    What I really want to see next is libxgrid so that I can use my debian/windows boxes as Xgrid nodes.

    My university had around 20 computer labs, some were packed, but some were completely empty. I understand that it'd use more energy, but if you could turn those into a cheap 'super computer' and loan/rent out time to groups on campus.

    1. Re:Now, libxgrid... by Ilgaz · · Score: 1

      Don't forget a great technology which everything under OS X (including iPhone) rely on is offered free on very same site with a very liberal license and not adopted by anything except FreeBSD. That is launchd , which created nothing rather than ''meh, xinetd'' in open source community.

      It is there, http://launchd.macosforge.org/ , Apache 2.0 license.

    2. Re:Now, libxgrid... by Anonymous Coward · · Score: 0

      Have you checked Condor?

    3. Re:Now, libxgrid... by ducomputergeek · · Score: 1

      Xgrid is basically Beep. I've able to get Linux nodes, and even FreeBSD nodes to attach to the system and preform basic tasks. I never went beyond that because it was more or less playing around with an old PC box.

      I did have 15 older Mac Minis up until a storm destroyed my house earlier this year. But I had a PowerMac with OS 10.4-Server and 15 Mac Minis (9 1.25/512, 5 1.42/512, 1 Core Solo (1.5Ghz I think) that I had picked up cheap. Used it for a few tasks like 3d animation and compressing video, etc..

      --
      "The problem with socialism is eventually you run out of other people's money" - Thatcher.
  29. Re:first post by Anonymous Coward · · Score: 0

    This isn't offtopic, it's perfectly accurate. Modded +1

  30. I just noticed a language trend by Anonymous Coward · · Score: 0

    People now say "multi-core" where they used to say "SMP." Deep down, they always mean the same thing (since people are always talking about software), so why did they change their wording? Because the most easily-available hardware changed. But the problems and solutions didn't change at all. It all sounds so new and sexy.

    1. Re:I just noticed a language trend by _LORAX_ · · Score: 2, Interesting

      SMP = Symmetric Multi-Processing. GCD, in theory, will also allow access to Asymmetric Multi-Processing as well since you can take advantage of GPU resources and cores as well.

    2. Re:I just noticed a language trend by sqlrob · · Score: 1

      multi-core != SMP. see: PS3.

    3. Re:I just noticed a language trend by alanQuatermain · · Score: 1

      GCD doesn't support using GPUsâ" that's what OpenCL is for. That said, there were some nice demos at WWDC where, for example, a solar-system modelling tool (tracking the gravitational movements of a zillion objects in real-time) was rewritten by adding first GCD then OpenCL. Using GCD to offload calculations to other threads in parallel made quite a difference, then OpenCL just blew the lid off. It was SCARY just how much difference it made. And the nice part was that GCD gave a nice performance boost by adding a couple of lines here & there to wrap little bits of long-running code in calls to dispatch_async().

  31. Exactly like vendor lock-in by mmacdona86 · · Score: 0

    A non-standard compiler extension that is guaranteed to be supported by the vendor's compilers is pretty much the definition of vendor lock-in, even if the implementation is open-sourced. If other compiler vendors don't pick it up (and they won't with a standards-based alternative) all code that uses it becomes tied to the vendor.

    1. Re:Exactly like vendor lock-in by sqlrob · · Score: 2, Insightful

      So you're saying gcc is being used for vendor lock in?

    2. Re:Exactly like vendor lock-in by Anonymous Coward · · Score: 0

      Supports both GCC and LLVM/Clang... both open source compilers last time I checked. Keep digging.

    3. Re:Exactly like vendor lock-in by alannon · · Score: 1

      The vender's (Apple's) compiler? You realize that you're talking about gcc, right?

    4. Re:Exactly like vendor lock-in by BasilBrush · · Score: 1

      The compiler (LLVM) is open source. Apple is a big contributor to the project, but it's not their compiler.

      LLVM will be the "standards based alternative". GCC is ugly and old, the whole point of LLVM is to replace it - generally, not just for Apple.

    5. Re:Exactly like vendor lock-in by Ant+P. · · Score: 1

      How is this any worse than writing code that uses GCC extensions? I bet you've already done that without realising it. Well, either that or you've never written a line of compiled code in your life.

    6. Re:Exactly like vendor lock-in by pohl · · Score: 1

      If other compiler vendors don't pick it up (and they won't with a standards-based alternative)

      What standards-based alternative do you have in mind? C++0x? You do know that's a C++ standard, right? Blocks are anonymous functions for plain C.

      --

      The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

  32. Server Security? by javalizard · · Score: 1

    If functions can now be data passed around as variables, doesn't this reduce the security of an application? Granted, you don't need to use blocks but i can envision a future world where internet server software is written heavily in blocks. What if a block makes it's way into the system from the outside world? Its the same thing as a code injection hack but this technology could potentially make it much more simple to do that. Yet another security concern.

    Given the new-ness of the technology it seems like some of these security issues need to be worked out... patterns developed and such.

    This technology strikes me as a solution for user experience issues and not bullet proofed for server solutions. I may be wrong.

    1. Re:Server Security? by cbreak · · Score: 1

      Allways sanitize your input.

  33. Re:Kamikaze development by Cajun+Hell · · Score: 1

    The problem with multi-threading isn't .. language support for nifty features

    Not the whole problem, but actually, yes, some of the problem is with languages.

    The problem with multi-threading is that some problems are damn hard to multi-thread

    And some problems are not hard to multi-thread, and yet reasonably competent programmers end up sometimes screwing it up anyway. They make mistakes not because they're stupid, but because (for example) they're in a hurry. (All professional programmers are in a hurry. Ship it! Next work order!!)

    There are ways we can make that situation easier.

    This will only make overconfident developers shoot themselves in the foot more quickly

    Ah, the old "power is dangerous" argument. You're right, and you're wrong, at the same time. Or rather, you are correct and irrelevant. Foot-shooters' problems are their problems. Your problems are your problems, and you don't want to have them. It's ok to make things easier for you. Don't worry about That Other Guy fucking up.

    --
    "Believe me!" -- Donald Trump
  34. Re:Erlang Anyone? Anyone? by Bill,+Shooter+of+Bul · · Score: 1

    Erlang is pretty cool, but I doubt the linux kernel or any other massive c codebase is going to be rewritten in it. GCD is an incremental improvement, that will be more likely to have a bigger impact.

    --
    Well.. maybe. Or Maybe not. But Definitely not sort of.
  35. Re:...what is it? Check the apple web site... by 644bd346996 · · Score: 5, Insightful

    What if you're running two applications that both are capable of monopolizing all your cpu time? How will your app know that it's only going to get 50% of the available cpu time form the OS, so it should only start threads for half the cpus?

    GCD decides how many threads a collection of tasks should be split across. If an app running on an 8-core machine wants to run 100 tasks, then they could be spread across anywhere from 1 to 8 threads, depending on what else is running. Since it's the OS that knows what else is running, it can make more intelligent decisions about how many threads should be running.

  36. The Key new feature of Grand central is by goombah99 · · Score: 5, Informative

    Grand central dispatch has many innovations, but the key feature it provides is that thread pooling is now handled by the OS not the program. This means that in a dynamic environment you don't have each application stepping on each other when they ask for too many threads --all total-- than the multi-core system can optimally handle. So if Mail asks for fifty threads and Firefox asks for fifty threads and CPU you are running on can realistically only handle 10 threads then GCD figures out how to manage things so you don't get a spinning beachball.

    It turns out a lot of tricks were required to do this including a lot of things like just in time compiling LVM and this C-Blocks stuff, but that's way over my head.

    --
    Some drink at the fountain of knowledge. Others just gargle.
    1. Re:The Key new feature of Grand central is by oatworm · · Score: 5, Informative

      Ars had a pretty good article on the subject. Fast-forward to page 8 of the review and go from there - they touch on LLVM, C blocks, and how Grand Central Dispatch works.

    2. Re:The Key new feature of Grand central is by deadkennedy · · Score: 1

      I guess the next best thing would be a library that handles the thread pooling and figures out how to manage things.

    3. Re:The Key new feature of Grand central is by node+3 · · Score: 1

      I guess the next best thing would be a library that handles the thread pooling and figures out how to manage things.

      That's what it is. It's called libdispatch.

    4. Re:The Key new feature of Grand central is by Hes+Nikke · · Score: 1

      And for those who are suffering from TL;DR, page 12 has the relevant section on GCD.

      --
      Don't call me back. Give me a call back. Bye. So yeah. But bye our, well, but alright we are on a shirt this chill.
    5. Re:The Key new feature of Grand central is by daybot · · Score: 1

      GCD figures out how to manage things so you don't get a spinning beachball

      For non-Mac OS X users who haven't heard that before, the spinning beachball is a cursor a bit like the hourglass.

  37. I've been working with it in C by wandazulu · · Score: 5, Informative

    I've come to really like GCD; I haven't played with it much in Cocoa (Obj-C) but I've been moving some of the stuff I wrote a long time ago in C to use it and I think I can say that what it does is *really* *really* awesome. It helps when writing code to be run in parallel; it does is not help you in determining *what* should be done in parallel. By putting your work into queues, by way of closures (yeah, blocks, whatever...I'm sticking with the closure name), it's up to the underlying OS to determine what thread gets what work, and on what processor. Having worked with multithreaded stuff on Windows, and calling GetThreadAffinityMask or whatever it was, and being told that it's just a *hint* to the OS, which is free to ignore you, which it always did, GCD really does spread out the work evenly among my 16-proc MacPro, and then turns around and does it just as well on the dual-core mini.

    I've wanted something like this for years; a really decent OS thread scheduler that divides up the work on the other processors in a sensible fashion. I was even looking into how much effort it would take to write something like this from scratch for Linux, and now I don't even have to. Sweet!

    Caveats: This is in OS X only, so no iPhone GCD (at least, not yet...not really necessary until we have multi-core iPhones), and while I've lived with additions to C++ through the years (templates mostly), the idea of adding, well, anything to C seems strange, let alone something as run-time dependent as closures.

    1. Re:I've been working with it in C by alanQuatermain · · Score: 2, Insightful

      it does is not help you in determining *what* should be done in parallel.

      I'd disagree slightly on that point; agreed, the technology doesn't actually make certain code blocks suddenly go "me! me! me!" but it does significantly ease the burden on the developer in making those decisions. I can throw something into the parallelization engine with a couple lines of code to see what difference that makes.

      The key example would be something like this one here, which Slashdot's filter doesn't like (it says please don't use so many junk characters, bah).

      That's a nice and simple change to make, and is easy to drop into any code which previously required synchronous execution. I can just wrap the existing synchronous code in two calls to dispatch_async(), one to throw stuff onto the background thread, and another to throw the last step back onto the foreground thread. If it doesn't help the program I can remove it. If it does help, I can leave it in.

    2. Re:I've been working with it in C by stephentyrone · · Score: 1

      16-proc MacPro

      O RLY? Where can I get me one of them?

      That aside, this is a pretty decent description of what GCD is good for.

    3. Re:I've been working with it in C by Smurf · · Score: 1

      With hyper-threading each processor core is treated by the operating system as two separate cores instead of one. Thus, a dual quad-core Mac Pro seems to have 16 processors.

      Granted, it is a far cry from actually having 16 separate cores, but in a multi-threaded efficient environment like the one provided by GCD you will see an improvement over an 8-core machine with no hyper-threading.

    4. Re:I've been working with it in C by DarkOx · · Score: 1

      That really depends on the work load. The PC world seems to have left HT behind. All the dual core systems I have show up as just two procs on smp aware kernels, as does my single core p4 with HT. Most things don't seem to get much if anything out of ht. Multiple decoders without the circuit resources behind them don't do much under the typical desktop PC load.

      I am certain there are applications that can see huge improvements from ht; must of the time that seconds decoders is sitting there wishing it could use the ALU.

      --
      Repeal the 17th Amendment TODAY! Also Please Read http://www.gnu.org/philosophy/right-to-read.html
    5. Re:I've been working with it in C by Anonymous Coward · · Score: 0

      You would have been right had it not been the case that Intel fixed their HT implementation in the Nehalem architecture. HT existed in the P4, but it was bad. Intel removed it in the Core and Core2 architectures. But Nehalem brought it back in a much, much better state.

  38. Re:Kamikaze development by ceoyoyo · · Score: 1

    I agree. Furthermore, these "high level language" things are just dangerous toys that let overconfident children shoot themselves in the feet more quickly. It should be the law that if you want to program a computer you have to use a real language - Assembly.

  39. Source by AP31R0N · · Score: 0, Troll

    Verbification weirds the language.

    --
    Utilizing the synergization of benchmark e-solutions to pre-workaround action items!
  40. Re: APSL, not BSDL by Anonymous Coward · · Score: 0

    Apple did not release Darwin under the BSDL. They re-release third party code under the licenses said code was distributed under, and most Apple written code used the Apple Public Source Licence.

    ***

    Example BSDL:

    Copyright (c) ,
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
    * Neither the name of the nor the
    names of its contributors may be used to endorse or promote products
    derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY
    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    ***

    Example APSL:

    APPLE PUBLIC SOURCE LICENSE
    Version 2.0 - August 6, 2003

    Please read this License carefully before downloading this software. By downloading or using this software, you are agreeing to be bound by the terms of this License. If you do not or cannot agree to the terms of this License, please do not download or use the software.

    Apple Note: In January 2007, Apple changed its corporate name from "Apple Computer, Inc." to "Apple Inc." This change has been reflected below and copyright years updated, but no other changes have been made to the APSL 2.0.

    1. General; Definitions. This License applies to any program or other work which Apple Inc. ("Apple") makes publicly available and which contains a notice placed by Apple identifying such program or work as "Original Code" and stating that it is subject to the terms of this Apple Public Source License version 2.0 ("License"). As used in this License:

    1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is the grantor of rights, (i) claims of patents that are now or hereafter acquired, owned by or assigned to Apple and (ii) that cover subject matter contained in the Original Code, but only to the extent necessary to use, reproduce and/or distribute the Original Code without infringement; and (b) in the case where You are the grantor of rights, (i) claims of patents that are now or hereafter acquired, owned by or assigned to You and (ii) that cover subject matter in Your Modifications, taken alone or in combination with Original Code.

    1.2 "Contributor" means any person or entity that creates or contributes to the creation of Modifications.

    1.3 "Covered Code" means the Original Code, Modifications, the combination of Original Code and any Modifications, and/or any respective portions thereof.

    1.4 "Externally Deploy" means: (a) to sublicense, distribute or otherwise make Covered Code available, directly or indirectly, to anyone other than You; and/or (b) to use Covered Code, alone or as part of a Larger Work, in any way to provi

  41. How about just callable objects? by Punto · · Score: 1

    I don't mind progress, and new standards and all that, and the idea of a "user-friendly scheduler" is really nice, but how hard would it be to make this work with just generic callable objects? it's not that hard to implement a closure in C, and it's been done for years for things like boost and libsigc++ (any signal/callback system that doesn't have upvalues is useless to me at this point). And it's not like these "blocks" are actually compiled and linked at run time, it's just a pointer to a static function with a bunch of extra data on it. If the API just took a callable object (which could be implemented as a "block" if the functionality was there), there'd be no need to wait for some committee to get together and approve an addition to a standard.

    --

    --
    Stay tuned for some shock and awe coming right up after this messages!

    1. Re:How about just callable objects? by Brian+Feldman · · Score: 1

      Better yet, we should implement the callable objects in assembly!

      --
      Brian Fundakowski Feldman
    2. Re:How about just callable objects? by metamatic · · Score: 1

      I don't mind progress, and new standards and all that, and the idea of a "user-friendly scheduler" is really nice, but how hard would it be to make this work with just generic callable objects? it's not that hard to implement a closure in C, and it's been done for years for things like boost and libsigc++ (any signal/callback system that doesn't have upvalues is useless to me at this point).

      Well, boost and libsigc++ are C++, not C, and Apple doesn't use C++.

      And implementing closures in C is exactly what they've done.

      Co I'm not really sure what your complaint is.

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    3. Re:How about just callable objects? by gabebear · · Score: 1

      The main thing GCD and Blocks are adding is allowing the compiler/OS to be aware of closures. This is what allows GCD to schedule the work in a closure intelligently ... hopefully

      Apple's closure syntax is pretty nice and works in C, C++, ObjC, and ObjC++. I don't think any existing syntax would work in an ObjC++ environment.

    4. Re:How about just callable objects? by tyrione · · Score: 1

      I don't mind progress, and new standards and all that, and the idea of a "user-friendly scheduler" is really nice, but how hard would it be to make this work with just generic callable objects? it's not that hard to implement a closure in C, and it's been done for years for things like boost and libsigc++ (any signal/callback system that doesn't have upvalues is useless to me at this point).

      Well, boost and libsigc++ are C++, not C, and Apple doesn't use C++.

      And implementing closures in C is exactly what they've done.

      Co I'm not really sure what your complaint is.

      What the hell do you think I/O Kit is written in?

    5. Re:How about just callable objects? by metamatic · · Score: 1

      What the hell do you think I/O Kit is written in?

      A subset of Embedded-C++.

      There's probably an interesting story behind why that one library is C++ when practically everything else is C or Objective-C, including its predecessor...

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
  42. More information and some concrete examples by Anonymous Coward · · Score: 0

    Mike Ash has a series of articles on GCD. He talks about what it is, how to use it, and why to use it.

    http://www.mikeash.com/?page=pyblog/

  43. Re: by TomC2 · · Score: 1

    Please tell me I was not the only one who was expecting a railway signalling system....

  44. Re:Kamikaze development by Anonymous Coward · · Score: 0

    Do you honestly think MS is going to pick up GCD? As soon as you start using it for the mac version of your multiplatform software, it becomes more complex to support both platforms easily. You either add a lot more development time (read: money) to add this to only one of your code bases, making it more difficult to track problems that affect both, or you don't use it at all (making GCD useless to you) or you drop Windows support (most likely cutting off 90% of your potential userbase for a desktop application).

  45. Hie thee hence! by Anonymous Coward · · Score: 0

    Go back to 1chan PS: F40PH

  46. Re:Kamikaze development by gwappo · · Score: 1

    You are posting in a thread about the fact that Apple made their implementation open source and you are claiming vendor lock-in?

    Are you one of those rabid Apple-haters we see so often around here? Or are you just amazingly stupid?

    I must be amazingly stupid because I rather like Apple products.

    Proprietary extensions are done for (arguably) the same reason by Microsoft; the goal should instead be to work on better iterations of language standards (C/C++) and not on introducing arbitrary language extensions that are not portable across compilers - especially not really extremely awkward ones like 'anonymous function pointers.' There's a similar argument to be made for 'encouraging' developers to use C# and Objective C.

  47. Comparisons with Other Technology? by David+Greene · · Score: 1

    I must confess after reading comments here and the Wikipedia article, I'm not sure exactly what's novel here.

    The "blocks" concept is nothing more than a repacked version of futures as far as I can tell. C++0x has anaymous functions and futures libraries for C++ already exist. I can see value in adding this for C but I sure hope Apple isn't thinking of trying to introduce a competing proposal for C++. We're way beyond that stage.

    And I really don't get the connection to LLVM and jitting. What's the advantage?

    As for the programming model, futures or OpenMP seem a much better way of expressing these kinds of things and they exist today. Better yet would be automatic parallelism extracted by the compiler when possible. It's limited to loops mainly, but anything to relieve the programmer from specifying this stuff is a win.

    As for the scheduler, it seems Apple has simply decided that kernel threads are more flexible than user threads. That may be true, but this is an old argument. I just don't see the novelty.

    Can someone enlighten me? An efficient implementation of threads for MacOS is certainly important so I'm not denying that the technology is important. But I don't understand the hype about it being somehow revolutionary.

    --

    1. Re:Comparisons with Other Technology? by WilyCoder · · Score: 1

      You no longer have to worry about which thread is on which CPU (scheduling). You simply make a thread and OpenCL determines which core to run the thread on. It saves a lot of work.

      That's my take on it anyways.

    2. Re:Comparisons with Other Technology? by David+Greene · · Score: 2, Insightful

      That's great and all, but systems have been doing this for years. When I launch a thread on Linux I don't care where it ends up. The scheduler takes care of it. Same with Perl, pthreads, OpenMP and pretty much every other threading technology I've ever used.

      What's new here?

      --

    3. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      You're absolutely right. You could also consider it a reimplementation of Intel's TBB or Thread Building Blocks.

      It's really not revolutionary at all... but that is how Apple operates. They reinvent the wheel and claim responsibility for it with incisive and effective marketing at every turn.

      Actually, within the Microsoft platform, this sort of thing isn't even necessary because they've been aggressive about multi-threaded applications since the 90's.

    4. Re:Comparisons with Other Technology? by shutdown+-p+now · · Score: 2, Informative

      That's great and all, but systems have been doing this for years. When I launch a thread on Linux I don't care where it ends up. The scheduler takes care of it. Same with Perl, pthreads, OpenMP and pretty much every other threading technology I've ever used.

      What's new here?

      With GCD, you don't "launch a thread". You "start a task", and how it is scheduled in a thread pool is up to the library. You don't muck around with locks, either - you define dependencies between tasks, and they're scheduled accordingly.

      Why don't you just look at some examples of GCD use, and see for yourself? It really is much clearer to see the code in this case.

      Microsoft has a very similar thing, by the way - Parallel Patterns Library - except that one is for C++ only, and uses C++0x lambdas rather than a (currently) proprietary C extension. But central ideas, and use patterns, are very similar.

    5. Re:Comparisons with Other Technology? by David+Greene · · Score: 1

      With GCD, you don't "launch a thread". You "start a task", and how it is scheduled in a thread pool is up to the library.

      So it's like a future. Or OpenMP tasks.

      Why don't you just look at some examples of GCD use, and see for yourself? It really is much clearer to see the code in this case.

      Yes, I did look at some examples. Unfortunately they're all in Objective C, but I got the main ideas, I think. I'm just noting that there isn't anything novel here. There's no big leap in productivity for writing parallel programs. You acknowledge this by referencing Microsoft's implementation.

      There's nothing inherently bad about this. I was just hoping I might learn something new.

      --

    6. Re:Comparisons with Other Technology? by shutdown+-p+now · · Score: 1

      Yes, I did look at some examples. Unfortunately they're all in Objective C, but I got the main ideas, I think. I'm just noting that there isn't anything novel here. There's no big leap in productivity for writing parallel programs. You acknowledge this by referencing Microsoft's implementation.

      There's nothing inherently bad about this. I was just hoping I might learn something new.

      There's nothing new here in the big scheme of things, in a sense that this approach was known for a long time now, and there were production-quality libraries in existence before. The big deal is that major players - Apple and MS - are now including this as core part of their software development stacks. GCD is in Snow Leopard, PPL (and PLINQ, which is the .NET counterpart) will be in .NET 4.0. If I remember correctly, something similar is brewing up for the next major Java release as well.

      In other words, the big news is that this is becoming mainstream.

      And this definitely brings a fairly large leap in productivity when you compare it to manual thread-management techniques. Yes, this isn't STM (or something else that's supposed to be the silver bullet when it comes to parallel computing), but it is a move one step higher on the abstraction ladder, and the benefits are noticeable.

    7. Re:Comparisons with Other Technology? by gabebear · · Score: 1
      Hmmm... some misinformation... but that's how anyone associated with Microsoft operates...

      Windows 7 finally has a half intelligent thread scheduler, but it's nothing like this. http://www.tomshardware.com/reviews/intel-core-i5,2410-8.html

    8. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      The first consumer level version of NeXT was Mac OS X, so even if what you said were true, they would be on equal footing.

      Unfortunately, they're not.

      Like most Apple people, you're quick to the condescension but not very bright. Windows 3.1 was indeed quite single threaded, but Windows 95 presented a diverse range of multi-threaded models through COM and the Win32 API.

      See this archaic whitepaper:
      http://www.calsoftlabs.com/whitepapers/multithreading.html

      So, multi-threaded application development has been a matter of course on the Windows platform for a quite long time. GCD stands to retro-fit Mac OS X from the 80's to a full-blown 90's theading model.

      Modern application development on Windows is supposed to take place using .NET, which marshals and threads on a level quite beyond what OS X can offer.

      It's a very nice icon and a riveting marketing description, though. GCD is very modern looking.

    9. Re:Comparisons with Other Technology? by gabebear · · Score: 1

      Like most Apple people, you're quick to the condescension but not very bright. Windows 3.1 was indeed quite single threaded, but Windows 95 presented a diverse range of multi-threaded models through COM and the Win32 API.

      These threading models meant you launched the thread on the alternate CPU and your application was completely in control of the secondary CPU(s), the OS has nothing to do with threading. These threading models existed in Win3.1 via libraries and in MacOS 7.5.

      SMP threading(where the OS assigns applications/threads to CPUs) is where OSs actually come into play, and that was only introduced in the NT kernels.

      Modern application development on Windows is supposed to take place using .NET, which marshals and threads on a level quite beyond what OS X can offer.

      I've never heard anyone champion .Net for performance. Anyone care to elaborate on how Microsoft has taken threading to "a level quite beyond what OS X can offer" with .Net? .Net objects inherently support marshaling(unless you use unsafe code), but I didn't know that they are doing anything special with threads.

    10. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      These threading models meant you launched the thread on the alternate CPU and your application was completely in control of the secondary CPU(s), the OS has nothing to do with threading. These threading models existed in Win3.1 via libraries and in MacOS 7.5.

      SMP threading(where the OS assigns applications/threads to CPUs) is where OSs actually come into play, and that was only introduced in the NT kernels.

      If the UI thread/worker thread model adapted to the SMP threading properly, then I would say the model is multi-threaded. It's not nearly as awkward as UNIX threading. If the model can be adapted from the backend without recompiling the applications, then they're developed properly.

      Why couldn't you just say SMP at first? Is it because you were trying to drop in smarmy Mac FUD and just hope that no one knew anything about multi-threaded applications? Calling Windows 95 "single-threaded" and meaning that it's a single processor system seems a bit misleading.

      Windows Vista has an aggressive thread pooling API and part of the core of the .NET architecture involves the intelligent pooling of threads.

      If you've never heard anyone champion the performance potential of .NET, then you're clearly spending too much time around Apple people. There's nothing new about GCD... it's just Intel's TBB for Mac. I don't see any evidence otherwise.

      Apple can continue their game of technical catch-up, but as long as they stay ahead culturally and marketing wise we'll never hear the end of this bs.

    11. Re:Comparisons with Other Technology? by gabebear · · Score: 1

      Windows Vista has an aggressive thread pooling API

      .Net/Windows creates thread pools per process, which is exactly what all older thread pools do. GCD uses a system-wide thread pooling system which brings the cost of creating threads down to a few instructions.

      If you've never heard anyone champion the performance potential of .NET, then you're clearly spending too much time around Apple people.

      CLR performance seems to be comparable to Java's VM. Are any major programs written in .Net? http://dotneverland.blogspot.com/2008/07/yet-another-benchmark-of-clr-vs-jvm.html

    12. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      CLR performance seems to be comparable to Java's VM. Are any major programs written in .Net? http://dotneverland.blogspot.com/2008/07/yet-another-benchmark-of-clr-vs-jvm.html

      What? You're showing me some random blog by a linux/java advocate comparing a bubblesort across platforms? What does this have to do with writing applications? All you've got here is the efficiency of the JIT compilers when doing exactly the same irrelevant task. This is esoteric and abstract when compared to an application development task, where native functionality needs to be called (windowing, media, databases, etc) .NET is not really targeted at major applications. Its a rapid development environment for windows customers, in the same way that large parts of Solaris aren't written in Java and large parts of Mac OS X aren't written in Cocoa.

      .Net/Windows creates thread pools per process, which is exactly what all older thread pools do. GCD uses a system-wide thread pooling system which brings the cost of creating threads down to a few instructions.

      I am almost positive that .NET's threading pool is at least .NET-wide.

    13. Re:Comparisons with Other Technology? by gabebear · · Score: 1

      Why couldn't you just say SMP at first? Is it because you were trying to drop in smarmy Mac FUD and just hope that no one knew anything about multi-threaded applications? Calling Windows 95 "single-threaded" and meaning that it's a single processor system seems a bit misleading.

      Win95 wasn't multi-threaded in any meaningful way.

      Win95/98 were normally run in preemptive multitasking mode, but since any program could turn off the preemption in Win95/98, and often did, it wasn't any more stable. Technically, some Win3.1 programs were multi-threaded, and there are several thread implementations for DOS, so you could say Microsoft has never shipped an OS that doesn't support multi-threading...

    14. Re:Comparisons with Other Technology? by gabebear · · Score: 1
      So,

      Modern application development on Windows is supposed to take place using .NET, which marshals and threads on a level quite beyond what OS X can offer.

      however

      .NET is not really targeted at major applications. Its a rapid development environment for windows customers, in the same way that large parts of Solaris aren't written in Java and large parts of Mac OS X aren't written in Cocoa.

      Most Mac applications are written in Cocoa. The Finder was re-written in Cocoa for Snow Leopard from Carbon/C++ with some really nice speed boosts. Photoshop is still Carbon, but the next version is switching to Cocoa (they have no choice since Carbon64 was binned and they NEED the speed boost).

      There are quite a lot of major programs written in Java because it is very cross-platform.(i.e. Eclipse and most of Oracle's tools). Nobody is delusional enough to think they would get a speed boost by switching to Java though...

      I am almost positive that .NET's threading pool is at least .NET-wide.

      .Net's thread pool sizes are managed by each process... so no.

    15. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      .Net's thread pool sizes are managed by each process... so no.

      Wait, why would that be a bad thing?

      The only benefit to a thread pool is that the threads are pre-allocated for what you're using them for. Per-application thread-pooling is set up as such by design. There is no need for a "global thread pool" because the windows operating system completes these tasks using its scheduler.

      There really is no useful application of thread building blocks outside of retro-fitting parallelization in single-threaded applications without thinking too hard.

      The GCD model is a time saver for developers and a retro-fitting device, but thread-level optimization potential is lost when you have code switching for thread objects. Thread pools work per-process towards a cooperative scheduling model.

      There's no performance case for using something like GCD. It's simply an issue of convenience. This convenience is being brought to .NET 4.0 in case developers should want to utilize it in PLINQ, but there's no reason for a well-tuned application to need it.

      Windows doesn't do this because it's retarded. This entire concept is a simplification of a more advanced thread API. It sounds like Apple is advertising a lack of resolution in the ability to manipulate threads. There is likely no performance improvement gained from this behavior, or at least there wouldn't be in a system with an intelligent threading model like Windows... there simply isn't anything to optimize. Associating threads with processes is kind of meaningless because it's just a separation of what memory you use when you run, so the only association is where the thread local data is.

      It's just meaningless to move threads between processes, which is why we don't have a global thread pool in Windows and we likely won't be using one in the near future.

      This optimization sounds sort of arbitrary...

      In .NET in particular, there's already correct behavior implemented for declaring something asynchronous, so it gets implicitly scheduled anyway. .NET is not utilized by professional developers right now for legacy reasons, really. You would have to be very careful and have very intricate needs to beat the performance curve on .NET with a native application. The perceived overhead with .NET comes from its sparse use on Windows leading it to be activated and deactivated as applications call upon it.

      This feature is irrelevant because there is nothing wrong with Windows' threading on demand model. The technical case is just far too weak.

    16. Re:Comparisons with Other Technology? by gabebear · · Score: 1

      The only benefit to a thread pool is that the threads are pre-allocated for what you're using them for.

      In a per-process pool-thread setup, a lot of time is spent creating and destroying threads in each processes's pool. Having a global pool means you just keep the optimal number of threads around for the number of CPUs you have.

      Windows doesn't do this because it's retarded. This entire concept is a simplification of a more advanced thread API. It sounds like Apple is advertising a lack of resolution in the ability to manipulate threads. There is likely no performance improvement gained from this behavior, or at least there wouldn't be in a system with an intelligent threading model like Windows... there simply isn't anything to optimize

      Are you saying you can't bog down a Windows machine by creating way too many threads? Thread pools are great and can speed up a lot of tasks, but if every process created it's own thread pool your system would be unusable.

    17. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      In a per-process pool-thread setup, a lot of time is spent creating and destroying threads in each processes's pool. Having a global pool means you just keep the optimal number of threads around for the number of CPUs you have.

      The operating system should handle that adequately. That's why you're not programming on bare hardware. This happens during program initialization, sure, but its fractions of milliseconds. The applications are not constantly moving or manipulating threads in operation. The performance gain from this would be completely negligible. There are plenty of optimizing benefits within the VCC platform vs. GCC that would outshine this.

      Are you saying you can't bog down a Windows machine by creating way too many threads? Thread pools are great and can speed up a lot of tasks, but if every process created it's own thread pool your system would be unusable.

      Not unintentionally. Since the applications are allocating memory also, I would say you'd run out of memory long before threads. So, it wouldn't be any more possible than with Mac OS X and GCD.

      The Windows scheduler should be able to handle any reasonable load such as this adequately. If you throw asynchronous operations at .NET as such, it will simply handle them about as elegantly as the system has the resources to manage.

    18. Re:Comparisons with Other Technology? by gabebear · · Score: 1
      OK... so you think:
      1. Creating and destroying thread pools has negligible overhead, so Windows isn't losing much
      2. Having lots of threads running isn't a performance problem because any operating system will run out of memory before it can create enough threads to bog it down

      My response:

      1. Can you find a thread pooling article that doesn't include something like "there is a lot of overhead associated with creating and destroying a thread that has nothing to do with the work that the thread was created to perform in the first place"? http://msdn.microsoft.com/en-us/magazine/cc164139.aspx
      2. It looks like .Net/Windows performance peeks at ~20 concurrent threads per CPU. By 50 concurrent threads you've taken a 30% hit in execution time. http://aviadezra.blogspot.com/2009/04/task-parallel-library-parallel.html and http://msdn.microsoft.com/en-us/magazine/dd252943.aspx
        • Pools trying to tighten their number of threads on an unloaded system will take an even bigger hit; the difference between 5 and 20 concurrent threads can be several orders of magnitude.

      You are simply wrong

    19. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      So, now we're talking about the fiercely thread-managed CLR environment again, right?

      I'm sorry, but Windows just isn't hitting this wall on a comparable desktop context.

      My scheduler is managing the 568 threads on my system just fine. I don't see how a dedicated thread pool would drastically reduce this overhead for a common usage scenario.

      These articles are likely far more relevant on large super-parallel systems running in a server context. Mac OS X is simply a desktop operating system, so Microsof's interest in PLINQ in .NET likely doesn't translate to some sort of related crisis for desktop users.

      How many concurrent threads absolutely does a desktop system need to run? Intelligent scheduling should make this a nonissue and unnoticeable to the average user.

      I'm sorry, this is simply an arbitrary optimization for a strictly desktop operating system. I can't see this having any major benefit unless the user's workload becomes more comparable to that of a massively parallel server. .NET is used heavily in enterprise servers, so their interest in parallelism is likely directed towards an entirely different technology base.

    20. Re:Comparisons with Other Technology? by gabebear · · Score: 1

      I don't see how a dedicated thread pool would drastically reduce this overhead for a common usage scenario.

      Fine, don't see it.

    21. Re:Comparisons with Other Technology? by malevolentjelly · · Score: 1

      Maybe Microsoft's approach to threading and scheduling would make more sense to you if it had a pretty icon and a pretentious marketing description attached to it.

  48. "open source"? what license! by Anonymous Coward · · Score: 0

    Saying something is open source is rather meaningless, just tell us the license name, bitches.

    1. Re:"open source"? what license! by lordholm · · Score: 1

      Click the link... one of the first things that will hit you in the head is the line saying "Apache License, version 2.0".

      --
      "Civis Europaeus sum!"
  49. Re:...what is it? Check the apple web site... by abigor · · Score: 1

    It also adds anonymous blocks to C, which is pretty radical. Read the Ars review on Snow Leopard, and skip ahead to the GCD parts - simply put, it is quite awesome.

  50. But you already have it... by malevolentjelly · · Score: 1

    GCD seems to be little more than an implementation of Intel's Thread Building Blocks adapted to Apple's platform:

    http://www.threadingbuildingblocks.org/

    So, in a sense, you as Linux users already have it.

    This technology is very valuable to massive single-threaded application such as legacy or poorly-implemented UNIX applications. This shouldn't be necessary on the Microsoft platform, which has been fully multi-threaded as a standard practice since the 90's.

    If Apple has made the technology more developer accessible, then this will be a valuable contribution to the Linux platform.

    In short, Apple is giving it away because it has no proprietary value. They probably just want free labor for maintaining their fork of TBB.

    1. Re:But you already have it... by Anonymous Coward · · Score: 0

      This technology is very valuable to massive single-threaded application such as legacy or poorly-implemented UNIX applications. This shouldn't be necessary on the Microsoft platform, which has been fully multi-threaded as a standard practice since the 90's.

      What are you talking about?

    2. Re:But you already have it... by Anonymous Coward · · Score: 0

      First, Microsoft's first consumer OS that wasn't explicitly single-threaded was WinXP

      No, Windows 95 was multithreaded. You're thinking Windows 3.x.

    3. Re:But you already have it... by Dr.Ruud · · Score: 1

      Well, threading is a thing of the past. Parallel processing is much more predictable when done with independent processes that partly do double work and get merged at the end. Not very green indeed, but still much closer to what we need.

    4. Re:But you already have it... by malevolentjelly · · Score: 1

      Well, threading is a thing of the past.

      I highly doubt this. I would say that in the age of multicore, logically separating threads to be managed by a central resource-adaptable API is going to become a lot more popular.

      This approach makes sense with desktop/mobile.

  51. Re:...what is it? Check the apple web site... by yabos · · Score: 1

    Yes, obviously the OS X kernel already manages the threads. The thing that GCD manages is creating the threads based on current system work loads and the tasks that you give it. If you give it 1000 tasks on a 4 core machine and the FLASH plugin is hogging 100% of one core(as it does a lot), GCD may start 3 threads and when you quit the web browser, it will likely start another thread.

    In general with most multithreaded programs, you probably start 1 thread per core because you can reasonably assume that this will perform pretty well if there's not much else going on. GCD is running at the OS level so it knows whether there is load on one core and if the other cores are free. Thus it will not start too many threads which will cause more context switching and degrade performance.

  52. Threads vs Cores by angelbunny · · Score: 1

    What I'm more interested in is the overall productivity. I'm tired of seeing operating systems treat threads like multiple cores. An i7 is not an 8 core cpu! There is a difference between threads and cores.

    When you look at how threads can share cache with each other it becomes obvious that threads can potentially become more productive than cores especially with tasks that need such power.

    So the in the end the question in my mind with GCD is, "Does it identify how much memory each queue needs and if the queues share memory? Does GCD do this to manage everything organizing what goes to what thread allowing a speedup especially when needed? Or does it treat threads the same as cores like everything before it?"

    My current computer only has a core 2 duo in it so I can not properly run tests but the second I get an i7 I'm going to run multiple tests with GCD, openCL, openMP, ... and see if anything can properly take advantage of threads managing the cache properly. Maybe this is an over the top openCL type task but regardless I wouldn't mind looking at GCD in detail to understand how it figures out the best way to manage the queues.

    imho memory management can be the best speedup, not how many numbers can be processed in a given time.

    1. Re:Threads vs Cores by Chirs · · Score: 1

      'So the in the end the question in my mind with GCD is, "Does it identify how much memory each queue needs and if the queues share memory?"'

      Doesn't matter. That's an implementation detail that can be optimized later and all apps making use of the API will gain performance.

  53. How ignorant and lazy you are by Santana · · Score: 4, Insightful

    I'm honestly surprised how ignorant and lazy the regular slashdotter has become with the years.

    Any self-respected geek should be already keeping up to date with Apple advancements which are and will be impacting techology in the years to come.

    If you people haven't noticed already, Apple has been consistently releasing libraries and server software as open source projects for the rest to pick up , use and modify, with liberal licenses.

    A friend of mine used to say (can't remember exactly... paraphrasing:)

    * Microsoft wants all software to be theirs
    * GNU wants all software to be free
    * BSD wants all software to be better

    And releasing GCD, gentlemen, is another master stroke by Apple, just like WebKit, Bonjour, LLVM, the list goes on, to share knowledge and advance technology by merit, not by forcing it down your throat thanks to the monopoly you have been handed.

    The term "block" is familiar to Ruby programmers. It's an old concept which Ruby has made easy to use and hence popular and actually useful.

    And here's another lesson which OpenBSD, Apple and Ruby have been putting to work without you noticing guys: any technology that is difficult to use, no matter how good it is, will not be used if gets in your way; the technology must be easy to deploy/use and unobstrusive to be actually used and useful.

    Just remember SELinux and how many people just disable it, no matter how good it is (which I don't think it is, but that's for another rant). Then compare it with the technology that OpenBSD has been implementing for memory protection which is unobstrusive and ready to use with no extra configuration. Same with Ruby blocks, which more programmers are using and a lot of software is benefitting from it now, even though higher order functions and closures have been around for ages.

    Having Ruby-like blocks in C and Objective-C is so COOL, you must appreciate that if you think you're serious at programming. Apple has already submitted it to be a standard. I believe MacRuby will benefit from this too, which is Ruby written in Objective-C, which implements Ruby classes as Objective-C classes, achieving incredible speed, taking advantage of Objective-C and LLVM technologies.

    Now, I want my late '90s Slashdot back please, where you could more easily find insightful and informative comments. There's a lot of garbage and Microsoft apologists nowadays.

    --
    The best way to predict the future is to invent it
    1. Re:How ignorant and lazy you are by 0xdeadbeef · · Score: 0, Troll

      And releasing GCD, gentlemen, is another master stroke by Apple, just like WebKit, Bonjour, LLVM, the list goes on, to share knowledge and advance technology by merit, not by forcing it down your throat thanks to the monopoly you have been handed.

      Or because all of those things were originally developed outside of Apple, and even they don't have enough magic fanboy dust to deflect the bad karma that comes from appropriating open source software without giving it back. I'll consider Apple part of the community when people can actually do whatever they want with the Apple hardware they own.

      There's a lot of garbage and Microsoft apologists nowadays.

      You people are like the people who believe that criticizing Christianity equates to appeasing to Islam.

    2. Re:How ignorant and lazy you are by Bluesman · · Score: 1

      Any self-respected geek should be already keeping up to date with Apple advancements which are and will be impacting techology in the years to come.

      Are you kidding? Just because the guy didn't know the latest buzzword for closures and first-class functions?

      This isn't new. This is 70's-era ideas just barely making it to the mainstream in a shiny package.

      --
      If moderation could change anything, it would be illegal.
    3. Re:How ignorant and lazy you are by Guy+Harris · · Score: 2, Insightful

      And releasing GCD, gentlemen, is another master stroke by Apple, just like WebKit, Bonjour, LLVM, the list goes on, to share knowledge and advance technology by merit, not by forcing it down your throat thanks to the monopoly you have been handed.

      Or because all of those things were originally developed outside of Apple, and even they don't have enough magic fanboy dust to deflect the bad karma that comes from appropriating open source software without giving it back.

      So who was it that originally developed GCD and the code to Bonjour?

    4. Re:How ignorant and lazy you are by Anonymous Coward · · Score: 0

      This isn't new. This is 70's-era ideas just barely making it to the mainstream in a shiny package.

      And it's about time! Closures and first-class functions are too important to ignore.

    5. Re:How ignorant and lazy you are by Anonymous Coward · · Score: 0

      achieving incredible speed, taking advantage of Objective-C and LLVM technologies.

      And you expect us to listen to you when you use the word 'technologies' like someone from a marketing department

    6. Re:How ignorant and lazy you are by Anonymous Coward · · Score: 0

      Just remember SELinux and how many people just disable it, no matter how good it is (which I don't think it is, but that's for another rant). Then compare it with the technology that OpenBSD has been implementing for memory protection which is unobstrusive and ready to use with no extra configuration.

      SELinux is more than just memory protection. A lot more. Go back and learn.

    7. Re:How ignorant and lazy you are by Anonymous Coward · · Score: 0

      Bonjoure is based on and a continutiation of zeroconf.

      GCD is pretty new, needs a new compiler etc etc. Not to say that they havn't used other peoples work as a base. But GCD is Apples no question about it and it is opensource.

      Why critizie apple for using Opensource the way opensource is meant to be? Linux geeks with no clue?

      Webkit it's apples also even thoug they did not write it from scratch, it's opensource. You take someones project and improve on it the way you want it improved. Give it out as a new package and get opensource community to work on it. That is the whole idea of OpenSoruce and that is the whole part of Opensource that most Linux user are totally missing.

      For the Opensource is = Free. Sorry guys you missed the consept of what Opensource is and how it should be utilized.

      For me :
      OSX most usable OS,
      Windows most used unusable OS,
      Linux not most used and not usabel as osx.

      why linux when there was/is, bsd, freebsd etc etc ???

    8. Re:How ignorant and lazy you are by Anonymous Coward · · Score: 0

      I'm honestly surprised how ignorant and lazy the regular slashdotter has become with the years.

      Any self-respected geek should be already keeping up to date with Apple advancements which are and will be impacting techology in the years to come.

      So much of the Apple stuff is over-hyped, and the Apple fanbois are so insufferable, that I don't blame ANYONE for not keeping track.

                I don't actually disagree with the rest of your post though, they've done some good work.

  54. Excellent, but apple isn't the first! by itsybitsy · · Score: 1

    Systems like GCD from apple have been around for quite some time.

    IBM Visual Age Smalltalk has had something like GCD for at least a decade. Smalltalk has had blocks since 1972.

    "When I first heard about Grand Central Dispatch, I was extremely skeptical. The greatest minds in computer science have been working for decades on the problem of how best to extract parallelism from computing workloads. Now here was Apple apparently promising to solve this problem. Ridiculous."

    Yes, ridiculous since Apple didn't invent it nor did they point out to you all the pit falls of using it. Remember they are a marketing organization and all their publicaly available materials paint a happy wonderful veneer on it.

    The truth is that concurrency control is difficult and concurrency control via something like GCD is just as difficult and avoids none of the real serious problems.

    I spent a year and a half debugging an in house application for a very large fortune 500 company that made use of this sort of capability for dispatching parallel work. Much of that time was tracking down problems in block oriented concurrency in a very large code base. Programmers assumed that what they were doing was safe but in the end those assumptions often turned out wrong. Data being changed by multiple threads is a serious problem. Locks are needed to avoid data corruption in many cases. That's just one example. Very nasty situations developed that required some very smart people to figure out and find solutions for, and we had a team of the very best. Eventually we identified the issues and found solutions. It took eight experienced developers over a year focused on fixing bugs that were derived from naive application of block oriented parallelism.

    Look, if all you have are very simple cases you're home free with GCD. That is nothing new of course as it is with any concurrency. The challenge comes in when your code base grows, changes and your simple cases are no longer simple. The assumptions change.

    So learn to use GCD wisely, it's not a magic silver bullet like it's being made out to be by Apple's marketing department. Oh and remember that C isn't as powerful a IDE as Smalltalk so you'll have your work cut out for you debugging any serious concurrency issues in your applications that use GCD, especially if they are huge applications.

    I do welcome blocks to C, finally some expressive power that Smalltalk has had since 1972!

    1. Re:Excellent, but apple isn't the first! by SuperKendall · · Score: 1

      You seem to be thinking that GCD *is* blocks, when Blocks are simply the mechanism you use to tell GCD what components can be executed in parallel.

      Yes many other languages have had closures. Not many other systems have had a system wide thread pool instead of application specific thread pools.

      No it doesn't help in the slightest with the issues of resource contention across threads. But anything that makes defining the parts to be executed in parallel easier, makes thinking about what resources might be in contention easier - and the smaller the blocks of work in question the less likely you'll trip yourself up with contention as well.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    2. Re:Excellent, but apple isn't the first! by Anonymous Coward · · Score: 0

      The threadpools are still process specific. The difference is only that the process-bound dispatchers inquire with the kernel as to whether or not they should allocate additional threads. Those threads are and remain bound to that process. They cannot go off and do work for another process. This difference is purely academic as pretty much every threadpooling mechanism inquires with the OS as to whether or not it is appropriate to create more threads to handle the queued tasks.

    3. Re:Excellent, but apple isn't the first! by itsybitsy · · Score: 1

      No I don't seem to be thinking just that. I am aware of their shared thread pool concept. It's irrelevant other than as a time optimization benefit.

      GCD from the programmers point of view within their application IS BLOCKS! That's how I approach it as I have in Smalltalk for decades. It's trivial to create the thread pool solution that Apple came up with (once I've examined their source I'll be able to confirm that for sure), at least it would be in Smalltalk.

      The challenge IS managing your objects and types in your program so that they don't end up with all the nasty problems that happen with non-trivial concurrency cases.

      For things like graphics it's likely there is no overlap of the data or the data is all read only anyhow since core graphics creates new bitmaps so this will work great with GPGPUs and multi-cores. The problem is business logic that is twisted and complicated as it usually is. The problem is control logic and avoiding deadlocks or live locks or a whole host of other things.

      My main problem is the ga ga life is awesome and GCD taking on the Steve Jobs reality distortion field when the facts are much more sobering to behold.

      So sure GCD is nice because it's done by the OS vendor mostly as long as you're doing simple stuff then you'll need a bit more of a concurrency education and hopefully not the hard way.

    4. Re:Excellent, but apple isn't the first! by pohl · · Score: 1

      Actually, GCD from the programmers point of view is callbacks. For every function foo() in the GCD API that takes a block, there is a corresponding foo_f() that takes an ordinary function pointer. One can use blocks without using GCD. One can use GCD without using blocks.

      --

      The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

    5. Re:Excellent, but apple isn't the first! by itsybitsy · · Score: 1

      "Actually, GCD from the programmers point of view is callbacks. For every function foo() in the GCD API that takes a block, there is a corresponding foo_f() that takes an ordinary function pointer. One can use blocks without using GCD. One can use GCD without using blocks."

      Actually, GCD from the programmers point of view is Block Contexts with callbacks as a mere detail. Every function call IS a block context, or method context, or function context since they are simply the largest context unit of code that is permitted in C. One can use blocks without using GCD. One CANNOT use GCD without using block contexts in it's various forms.

      [:|]

    6. Re:Excellent, but apple isn't the first! by pohl · · Score: 2, Informative

      Blocks have some important properties that distinguish them from functions: they capture enclosing scope and can live beyond the lifetime of that enclosing scope. If the event handler that you want to put into a queue is an ordinary function pointer that has not captured enclosing state, you may do so. A type is provided: dispatch_function_t. Contrast this with dispatch_block_t while you're reading the API documentation. The very first paragraph under the heading "About Dispatch Queues" may help.

      --

      The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

    7. Re:Excellent, but apple isn't the first! by itsybitsy · · Score: 1

      In "C" blocks might have that distinction and limitation... but not in a fully Block Oriented Language where methods aka functions are unified with blocks.

      Functions also live beyond the life time of the enclosing scope, albeit in a different way, even in C. You have a pointer to the function and can activate it anytime.

      A function on a queue can easily access state stored in global or other scoped variables so it can access state. While this violates encapsulation that hasn't stopped the C programmers programs that I've had the misfortune of reading and fixing.

      Sure blocks have some attributes that C functions don't have. That isn't the point. I repeat, that isn't the point.

      The point is that GCD isn't really doing anything more than having chunks of code, either in a function (as was helpfully pointed out for completeness) or in a block context, run in various queues sharing threads that have already been started (usually) by the GCD manager code goo. GCD doesn't provide anything but the most simplistic concurrency controls, and it's worse in that Apple markets it as the new panacea silver bullet for solving concurrency problems magically.

      I'm simply cautioning people that it's not the silver bullet as advertised nor is it a particularly good or safe way to manage anything more than the simplistic cases of concurrency controls. All the complexities are there waiting to pounce upon you and your unsuspecting hoards of objective-c programmers. This is an observation derived working with a much more powerful language and a very similar concurrency control mechanism.

    8. Re:Excellent, but apple isn't the first! by pohl · · Score: 1

      Of course you are right to caution against the evils of the marketing literature. That's a good thing to remind people of. God knows I never tire of hearing it. Clearly your goal here is to prevent people from believing things about this technology that are not true, and that is laudable.

      That is my goal too. My only skin in this game was to make sure that nobody assumed that the Apple C blocks extension was a necessary part of GCD and its use. A naive reader might have read your emphatic claim that "GCD from the programmers point of view within their application IS BLOCKS!", and left the thread not knowing that GCD can also be useful without these smalltalkish additions to C.

      Sure, a lot of the real power of GCD rests on these closures, but not all applications need that sort of thing. Sometimes one is blessed with not having to share state among concurrent operations.

      Whatever point you were trying to make didn't matter to me, because your whole rant seemed to be based upon a straw-man argument: wherein you would have us believe that someone claimed that apple invented the thread pool or closures or something.

      I couldn't find where anyone actually made such claims, so I was tuning out everything except for those things that might misinform people about the system that was open sourced yesterday.

      --

      The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

    9. Re:Excellent, but apple isn't the first! by itsybitsy · · Score: 1

      I actually wasn't aware of the irrelevant detail that GCD can work just with function pointers independent of blocks. Apple advertises it as requiring blocks. Some of their literature says so. Regardless it's irrelevant since blocks can be used without any state being passed in which is the same as functions without any state being passed in.

      Ok, so we're talking cross purposes. No straw man intended. Apple does claim they invented a great way of doing concurrency to take advantage of multi-cores and GPGPUs. I wouldn't be surprised if patents were or are to be filed.

      No I wasn't claiming that apple invented closures, concurrency, thread pooling, or anything of the like. They claim to have invented the whole package known as GCD and that it's the new silver bullet solving all problems with concurrency. That's the problem. Some just don't get it, some programmers that is! I've argued with them on the phone about it in fact, people who should accept a logical argument and a factual description of the darn GCD thingi. But nope, they thought it's much more because of the Apple propaganda. Many in the /. comment thread for the posted story are doing the same. I'm simply being mr objective reality on the horrors of concurrency lurking around the corner for them. GCD isn't new, the patter is OLD! That was another point. Blocks in C are fantastic! That's a minor point but really important one.

  55. Don't forget CUPS! by andersh · · Score: 1

    Apple also hosts and continues to support CUPS, the Open Source printing system, a project they bought from the developer that owned it. http://www.cups.org/

    1. Re:Don't forget CUPS! by Guy+Harris · · Score: 1

      Apple also hosts and continues to support CUPS, the Open Source printing system, a project they bought from the developer that owned it. http://www.cups.org/

      ...and they hired said developer while they were at it.

  56. Re: a simple change, but a new race condition by Anonymous Coward · · Score: 0

    If 'self' happens to go away while that thread is running, the changed program will show undefined behaviour. These simple changes almost all require garbage collection to be robust.

  57. Very necessary... by SuperKendall · · Score: 1

    This is in OS X only, so no iPhone GCD (at least, not yet...not really necessary until we have multi-core iPhones)

    I disagree. As a former Scheme programmer I find it a bit maddening to be so close to have closures as a tool again, yet so far... after all, blocks/closures are a nice way to tell GCD just what you want scheduled, but there are plenty of other great uses for closures in day to day programming where you're not even thinking in parallel.

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

      You might find the Plausible Blocks project to be useful in the interim.

      --

      The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

  58. Not static by SuperKendall · · Score: 1

    And it's not like these "blocks" are actually compiled and linked at run time, it's just a pointer to a static function with a bunch of extra data on it.

    Not true, blocks can use any variable from the calling context and it will be incorporated at runtime. These are not just function pointers to static methods.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  59. Re:...what is it? Check the apple web site... by Bluesman · · Score: 1

    What if you're running two applications that both are capable of monopolizing all your cpu time?

    How often does this actually occur? And if it does and the processes are threaded, won't a smart OS scheduler just migrate the threads so that each application essentially has a CPU (or four) to itself?

    I think the big win is more likely that this makes threading on Mac easier. That said, I really hate the way they did this; putting high-level language features like lexical closures in C is just ugly. C is a glorified assembler, and should stay that way :-)

    --
    If moderation could change anything, it would be illegal.
  60. Re:Kamikaze development by Anonymous Coward · · Score: 0

    No kernel-level support is required for GCD (the kernel-level facilities are mere optimizations). The library is open-source. LLVM's compiler-rt implementation of the runtime support for blocks is available. Microsoft's involvement is not necessary in this case.

  61. idiots rule by pohl · · Score: 1

    As someone with experience responding to retards, in particular those with inflated self-evaluations of competency.... the above comment is garbage. It's absurd that the above post could be useful to anyone evaluating libdispatch. In particular, it ignores the forgone conclusion that porting this to linux or windows would entail the standard macro preprocessor magic to replace the mach calls with equivalents for other target platforms. Anybody actually evaluating libdispatch has seen ported C. Many times. While it's good to have a library that has already been ported, looking at the above comment, I think you'd have to be an idiot to think that the Mach primitives could not be conditionally compiled with #ifdef. Not to mention C++0x is a C++ standard, and this is a C library.

    --

    The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...

    1. Re:idiots rule by Anonymous Coward · · Score: 0

      Good code isn't written to be "portable" simply by using haphazardly placed #ifdefs all over your .c files.

      The code I looked at is pretty much throwaway junk, the kind of boiler plate that everybody writes in a concurrent app. The Mach-isms and notes about bug IDs in Apple's database are distracting to what the library is trying to accomplish. The whole thing looks pretty hackish and I can come up with something better in an afternoon. Give it a hyped name like "Grand Central" and release it from Cupertino and all of a sudden it's something to talk about?

    2. Re:idiots rule by Anonymous Coward · · Score: 0

      I'm sorry that you find it difficult to refactor trivial code. I'm sure that's not a comfortable skillset imbalance to have, but if you practice refactoring you can improve. The trick is to resist the impulse that feels easier to you: if you feel like throwing away and re-writing, refactor instead. Hang in there; keep the faith. Meanwhile, elsewhere on the internet, actual programmers are busy porting the code and handling the issues in stride. Before long their efforts will eclipse the importance of your "Meh" for all eternity.

    3. Re:idiots rule by Anonymous Coward · · Score: 0

      Since you take such a conciliatory tone, I might as well adopt it as well:

      I'm sorry you're so bad at concurrent programming that you need Apple to get the ball rolling for you on this library, that you can't realize it's boiler-plate that people have been writing and re-writing for decades, and nothing directly useful unless you don't understand the concepts involved.

    4. Re:idiots rule by Anonymous Coward · · Score: 0

      Having to write boilerplate code is generally considered a bad thing. No longer having to right it is generally considered good. If that's the worst criticism you can muster, then kudos to GCD.

  62. where your thread winds up by Anonymous Coward · · Score: 0

    Well, the primary difference being that there isn't any chance that your thread will wind up on another type of CPU. With an adroit and vigilant combination of OpenCL, GCD, and Blocks, your thread might wind up on the GPU, the CPU, or your fancy schmancy uber cool Cell auxiliary card.

  63. Fully Multithreaded !!! by Anonymous Coward · · Score: 0

    I'm really going to enjoy watching the "Fully multi-threaded as a standard practice since the 90's [sic]" environment of Windows (TM) crumble under its own weight when that mountain of OS and apps must be re-threaded to make them perform well on quad-core, then octo-core, then hexa-core...

  64. Internals by AlastairLynn · · Score: 1

    Basically, libdispatch just creates a thread pool for each separate task, then uses some clever magic involving an inter-process semaphore to keep them blocking so that no more than enough threads (ie: the number of CPUs) are running at any given time. Nifty, because it means little change needed to be made to xnu. libdispatch is also, theoretically, portable to other platforms, as long as one can provide a blocks runtime and a compiler capable of handling blocks. I noticed a patch on LLVM's mailing list today providing a Linux port of the blocks runtime, and llvm-gcc and clang both are capable of handling blocks and running on Linux.

  65. Re:Happy Birthday America!!! by Hucko · · Score: 1

    haha! weiner you mean Osama

    --
    Semi-automatic amateur armchair Australian philosopher; conjecture ready at any moment...
  66. Apache 2 license! by chrysalis · · Score: 1

    Why the heck did they release it under an Apache 2 license, and not under a regular BSD license?

    --
    {{.sig}}
  67. How's this different from a good thread-pool? by Anonymous Coward · · Score: 0

    May be I'm missing something here, but what this is saying is that I can take a lambda function and schedule it to run in a thread pool, and that the thread pool will dispatch work such that it makes good use of available CPUs and won't push further such that it would cause excess of context switching. How is that new? The Windows "I/O completion ports" mechanism has always been able to do the nice scheduling part, although with an ugly API. Then the newer Windows thread pool API layered nice thread management and work item dispatch on top. On top of all that, .NET has simply QueueUserWorkItem(delegate, context) that does exactly this, with lambdas and all.

    Am I missing something? Or there is really nothing new here other than the fact that Apple released an open source library with an API for this?

    1. Re:How's this different from a good thread-pool? by Anonymous Coward · · Score: 0

      This story is not about what makes GCD unique. Rather, the story is about libdispatch being made available under the Apache 2.0 license.

  68. Re:Erlang Anyone? Anyone? by blaster · · Score: 1

    Erlang is very cool, but it is not designed to replace C. In fact, it is designed to handle some bits of the higher level concurrency stuff and call out to C "drivers" for level work. Apparently Ericsson's switch code has almost as much C/C++ code as Erlang code. GCD addresses concurrency in problem spaces Erlang is completely inappropriate for, just like Erlang plays in spaces that GCD is not appropriate for. They are different tools for different jobs.

  69. Linux Need To Move On To GPL v3 by Anonymous Coward · · Score: 0

    Linux should be release under GPL v3 so it can be compatible with Apache license. This would help Linux move forward, invent, and advance the field of computer science instead of just trying to reinvent GCD, ZFS, DTRACE, ect..

  70. Exactly my thoughts by Santana · · Score: 1

    I would add "powerful" to your points (which I guess are limited to the desktop):

    * Mac OS X: usable and powerful (great UI + great foundation)
    * Windows: just plain convenient, thanks to the size of the install base and people familiar to it
    * GNU/Linux: powerful, but not usable

    Being said that, I'm actually using the three of them at work:

    * GNU/Linux for the people that is responsible for a few and very specific tasks for which Ubuntu has been customized.
    * Windows for the yet-to-be-converted PC because of in-house systems or 3rd party software that require Windows and is pending of getting an alternative
    * Mac OS X for people that know better. Which means the IT department :)

    --
    The best way to predict the future is to invent it
  71. Re: a simple change, but a new race condition by alanQuatermain · · Score: 1

    Garbage collection is robust enoughâ" the block gets copied to the (garbage collected) heap when it's passed into dispatch_async() or similar calls automatically, and it uses scanned memory to do so, meaning the collector tracks a refcount on 'self'.

    In non-collected situations, it's up to the developer to ensure that this doesn't happen somehowâ" for instance by retaining 'self' before the first dispatch_async() and releasing it inside the last block.

  72. Re:...what is it? Check the apple web site... by bhiestand · · Score: 1

    Not to mention that extra 10+ GB of free space :)

    --
    SWM seeks new sig for a brief fling