Subj : Re: Dual core and Multithreading To : comp.programming.threads From : David Butenhof Date : Tue Sep 27 2005 02:19 pm donotcareaboutspam@googlemail.com wrote: > Is it possible for one single process consisting of two threads to let > one thread run on one core and the other one on the other core? Or is > there a limitation which allows the all the threads of one process to > be executed on only one single core? "Virtually all" (if not all) multiprocessing schedulers that support dual core processors do so as if each core were a completely independent "CPU". There might be some advantage for treating it as a sort of "NUMA level" in the resource scheduling hierarchy, as "sibling" cores usually share some resources (like 2nd or 3rd level cache); though this varies by chip family and even model. However, whether this "slightly closer" resource association BENEFITS or HARMS any particular set of threads (or processes) is extremely difficult to determine dynamically; and therefore to factor into scheduling decisions. This becomes far more dramatic with "hyperthreading" cores, because the "threads" in a core are vastly more closely coupled than cores on a chip. Still, it's almost impossible to dynamically measure the real impact of that sharing on any particular set of threads so again most schedulers simply treat each "thread" as if it were an independent CPU. When hyperthreading first came on the scene there was a lot of serious consideration that one might want to schedule the core to a particular application and allow a higher-level (application domain) scheduler to determine how to allocate the threads of that core to software entities. So far as I know, nobody's actually done that, though. And a user-mode thread library, like libpthread, is still too low level to really be able to understand the resource relationships between threads enough to do that scheduling. A layered OpenMP library, though, might be able to do better; or a Java VM. -- Dave Butenhof, David.Butenhof@hp.com HP Utility Pricing software, POSIX thread consultant Manageability Solutions Lab (MSL), Hewlett-Packard Company 110 Spit Brook Road, ZK2/3-Q18, Nashua, NH 03062 .