Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 1, 2011, 09:15 PM   #1
Blakeasd
macrumors 6502a
 
Join Date: Dec 2009
Queues in Grand Dispatch Central

Is a queue equivalent to a processor core? If it is what happens if you create and use more cores than the user has, can you detect the number of cores a user has in GDC?
Blakeasd is offline   0 Reply With Quote
Old Jun 1, 2011, 09:21 PM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
A queue is not equal to a processor core.

The purpose of GCD is map queues to cores appropriately. Appropriately means not just the number of cores, but also taking into consideration total system workload.

Just create queues as needed and let GCD do the management. Having more queues than cores is the same as having more processes than CPUs, the operating system will manage it for you.

Don't be naive, though. Do create sequential and parallel queue intelligently for the tasks at hand. But the decision should be based around the nature of the tasks, not the user's environment.
jiminaus is offline   0 Reply With Quote
Old Jun 2, 2011, 01:08 AM   #3
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by Blakeasd View Post
Is a queue equivalent to a processor core? If it is what happens if you create and use more cores than the user has, can you detect the number of cores a user has in GDC?
_One_ asynchronous queue will use the exact right number of cores as needed for all tasks in the queue. How many cores depends on what other queues both in your application and in all other application are using; the OS will decide to optimise performance for everyone. Do _not_ create more queues in an attempt to use more cores, it doesn't work that way.
gnasher729 is offline   0 Reply With Quote
Old Jun 2, 2011, 03:45 PM   #4
Blakeasd
Thread Starter
macrumors 6502a
 
Join Date: Dec 2009
What exactly is a queue then?
Blakeasd is offline   0 Reply With Quote
Old Jun 2, 2011, 04:09 PM   #5
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by Blakeasd View Post
What exactly is a queue then?
An object responsible for executing blocks on multiple cores.

Apple spent probably lots of money for the salary of a technical writer documenting how dispatch queues work. You should make use of that money and read the documentation. If there is something you don't understand, post it here.
gnasher729 is offline   0 Reply With Quote
Old Jun 2, 2011, 05:37 PM   #6
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
The Concurrent Programming Guide is another good overview. It also talks about the higher-level NSOperationQueue, which was reimplemented on top of GCD in Mac OS X 10.6.
jiminaus is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Grand central station Kashchei OS X Mavericks (10.9) 1 Nov 16, 2013 01:04 AM
Grand central had all colors but spoken for brinycbri iPhone 0 Sep 20, 2013 06:29 PM
Resolved: Grand Central Dispatch multinode Mac Programming 2 Aug 31, 2013 12:25 AM
Books on Grand Central Dispatch klaxamazoo Mac Programming 4 Feb 3, 2013 11:32 AM
iPhone 5 - Grand Central Terminal Meetup slippery iPhone Launch Meetups 0 Sep 11, 2012 02:23 PM

Forum Jump

All times are GMT -5. The time now is 10:49 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC