Sign in with
Sign up | Sign in
Your question
Solved

How many threads can be made in a dual core?

Last response: in CPUs
Share
May 22, 2012 3:04:58 PM

I am using dual core.I am new for multithreading.

I used vb2005 and created new thread.

firstly, 1 thread worked. time to process 120sec
secondly,2 threads worked. time to process is about 60 seconds.
then,3 threads created. time to process is about 60 seconds.(not change to the time of 2 threads.)

Is it because, my hardware can only create 2 threads(for being dual)?

Also, I googled and found.
software thread=piece of code
Hardware thread=core(processor) for running software thread.
Am I true for this?

any help would be appreciated.

More about : threads made dual core

May 22, 2012 3:17:18 PM

Hi, generally speaking, the number of threads you can spawn do not depend on your CPU but on your copiler and run time, let me explain it. When you create a thread (or several) you are signaling the run time your intention to run that piece of code included in the htread in parallel with the rest of your program. Its up to the run time to negotiate with the Operating system how "parallel" the threads will be. Its the operating system and the hardware the ones that will launch and synchronize the threads, even if you have a single cpu core you may run multiple threads because the operating system will run each thread for a small amont of miliseconds, one after another giving you the illusion that you are running several tasks at once, when in fact you arent. Now with the cpu part, the modern CPUs do have several cores which means they can really run the threads at the same time. I recommend you to donwload the Tannenbaun book about operating systems to become familiar with the operating system theory. DId this answer your question or you have more doubts now? ;) 
m
0
l
May 22, 2012 3:48:44 PM

bietapico said:
Hi, generally speaking, the number of threads you can spawn do not depend on your CPU but on your copiler and run time, let me explain it. When you create a thread (or several) you are signaling the run time your intention to run that piece of code included in the htread in parallel with the rest of your program. Its up to the run time to negotiate with the Operating system how "parallel" the threads will be. Its the operating system and the hardware the ones that will launch and synchronize the threads, even if you have a single cpu core you may run multiple threads because the operating system will run each thread for a small amont of miliseconds, one after another giving you the illusion that you are running several tasks at once, when in fact you arent. Now with the cpu part, the modern CPUs do have several cores which means they can really run the threads at the same time. I recommend you to donwload the Tannenbaun book about operating systems to become familiar with the operating system theory. DId this answer your question or you have more doubts now? ;) 



Thank you for replying.

I understood what you said.

but,what happened to this?
firstly, 1 thread worked. time to process 120seconds.
secondly,2 threads worked. time to process is about 60 seconds.
then,3 threads created. time to process is about 60 seconds.(no change to the time of 2 threads.)


m
0
l
Related resources

Best solution

a b à CPUs
May 22, 2012 4:49:53 PM

houseinn2 said:
Thank you for replying.

I understood what you said.

but,what happened to this?
firstly, 1 thread worked. time to process 120seconds.
secondly,2 threads worked. time to process is about 60 seconds.
then,3 threads created. time to process is about 60 seconds.(no change to the time of 2 threads.)


If each thread uses 100% of the CPU then making 3 threads on a 2 thread computer has no benefit.

Share
a b à CPUs
May 22, 2012 5:10:07 PM

Basically, a single CPU core can execute ONE thread at any one time. You can spawn thousands, but only one can execute per CPU core at any one time.

Now, because threads can be IO blocked, moved to disk, or not run for a variety of reasons, if you have multiple things that need to be done that do not have to be executed in sequential order, it makes sense to spawn each task as its own thread, so if one thread can not be run [for whatever reason], your application can still get some work done, as opposed to none at all.
m
0
l
May 22, 2012 11:35:15 PM

2 remarks:

Gamerl316 "Basically, a single CPU core can execute ONE thread at any one time", as I said, the cpu executes millions of instructions each second, and switches from one task to another every few miliseconds giving you the illusion that is running several taks (threads) at the same time. For instance, windows, it has a "thread" that runs continually waiting for user input, be it moving the mouse, pressing a button..this thread is always active, even when you are playing games, music, etc. Again I highly recommend you to read the Tanenbaun manual, is very good and you will learn a lot
2 Why adding more threads is not giving you any additional benefits? one reason is Gamersk answer, but it could be also that your cpu is reaching its limit, or that simply the thread cannot be splitted more, for isntance as he mentioned you wont get much benefit for multithreading reading or writing operations from the file system.
m
0
l
May 23, 2012 4:28:03 AM

bietapico, gamerk316 ,Cazalan

bietapico, thank you for the book and the idea.pretty good info.

gamerk316, thank you for the IDEA.good knowledge.

Cazalan, thank for telling me there is no benefit."this helps me to stop thinking for more threads that i was going to make"
m
0
l
May 23, 2012 4:28:16 AM

Best answer selected by houseinn2.
m
0
l
!