Yes, I know the difference between 4 and 6 cores - what I want is an explanation of what threads are and how they relate to the quad and hexcore cpu's. I am trying to decide on a quad or hexcore and after learning some things I need help on this. Please answer. This appeared to be the best place to ask this question since a cpu is hardware and I am trying to figure out which one is most appropriate for programming software.
This may belong to Programmers Paradise, but I'll let them mods move it.
*What is a "thread"?
A thread is a unit of execution. So an application runs as a process, within processes a thread exists.
*What is a thread used for?
A program uses threads to run. All application have at least ONE thread.
*How do the number of threads affect cpu performance?
Loosely put - it depends. Most CPU's implement some sort of multi-tasking capacity - either it's time slicing or round-robin. It's hard to say about performance. Though, if an app spawns too many threads, it can eat up valuable CPU time.
*How many threads are there in a quad? In a hexcore?
Kind of an odd question because there isn't a law that goes thread == core/CPU. The OS handles thread management. See, when you launch an application (i.e., Process) it talks to the OS for resources. If it needs memory, it asks the OS. When you spawn (i.e., make) new threads, the application itself doesn't handle the thread, the OS does. The application tells the OS "hey, I have a new thread...so you might want to assign it a resource". So a four or six core CPU can execute thousands - if not, millions - of threads.
*Why can't current software take advantage of more threads?
Again, it largely depends. Remember that software is designed to solve a problem domain. That in mind, if software is designed to solve a problem then the number of threads needed is largely based on the problem at hand. It's difficult to say "Why can't current software take advantage of more threads?" because there are apps that are naturally multi-threaded (i.e., more than one thread). However, 90% of apps only need one thread. For example, SQL Server is highly threaded because it has to respond to a query and create an execution plan for it. Microsoft Word is not heavily threaded (if at all) because it mostly does one thing (write, save/print)./
*What apps do you know of that currently take advantage of the additional two cores in hexcore cpu's? Please mention one or more if you can.
SQL Server, Folding at Home, SETI at Home...
In cases like these, they may not have multiple threads but have parallel tasks. So they may not be multi-threaded but they execute parallel tasks. SQL Server is a VERY threaded application. Web Servers like Apache or IIS are also heavily threaded since each browser request is a thread of execution.
*Do you own a hexcore? If so, which one? Have you seen a difference between this hexcore and any prior cpu's you have owned?
I own a quad-core, and no, there's no real difference in performance of stuff I write. Though, Bad Company 2 does run faster on my new quad-core i5-2500K than it did on my Core 2 Duo.
I am also interested in programming. If you know, how would I create an application that actually takes advantage of the extra threads in the hexcore and
what language or compiler could do that best? C++? Not sure. Please suggest a software compiler that would work best.
I'm not a master of threaded apps, so take this as more of a launch point for your research.
Every language is designed to solve a particular problem and many of these same languages can spawn one or more threads. C/C++ uses POSIX threading, which is a PITA to write for. C# uses a similar POSIX model but is more user-friendly. Java is also multi-threaded, and it does it well. Ruby doesn't use threads, it uses fibers. Python is threaded. Now, Erlang, is designed to be multi-threaded and scalable.
My advice to you (and I"m sure people will back me up):
- If you're interested in programming, start with programming.
- Don't worry too much about threading. Threading has its own set of devils: devils that you do not want to encounter early on. For example, some error conditions are deadlocks and race conditions. Threading is advanced, skip it for now but keep it in the back of your mind.
- 90% of the problems you will solve do not involve threads. Even the most algorithmic solution you can think, generally can be ran on a single thread.
- You'll understand that threading is not the same as parallelism. Threads are not really core aware because you can have five threads being processed by two out of four cores. CPU scheduling dictates which resources go into which CPU. However, parallelism is far more unique - because if a thread is a single instance of work, parallelism takes work and breaks it down to multiple cores/CPU's. You can have an app with a single thread but if it uses parallelism, then it can distribute work efficiently against all CPU's and cores. Again, this is advanced topic, do NOT worry too much about it.