in Perl the main thread gets a priority, and the time slice gets divided amoung the it's threads..... no concurrency..
Sorry Zentara, but that is absolute and utter baloney.
Be it pthreads under *nix, or native threads under Win, both are native kernel threads! As such, the will each receive their own timeslices from the kernel; and on multi-cored & multi-cpu'd machines, are eligiable to run on all cores.
I really did think you knew better?
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
.... all i'm saying is he shouldn't think Perl threads will make it go faster
.... he cannot gaurantee his multicore system will split the Perl threads between cores....in all likelyhood, it will be run in the same core, meaning both his threads will share a single execution pointer..... the pointer can't be in 2 places at the same time and the nice value given to the main thread, will limit his total speed
...if you have a code snippet that shows you how to force a Perl process to split it's execution across multiple cores, i would like to see it.... i could learn something
..... i don't know how many times this has been argued.... but Perl threads actually slow you down on a single cpu machine.... you may as well just have it all in the main script.... but on a multi-core system, on windows, it may work better..... but i'm just advising him, so he dosn't think Perl threads are some miracle speed boost thru concurrency
.... Perl Threads and multi-core CPUs discusses the pitfalls
| [reply] |
.... all i'm saying is he shouldn't think Perl threads will make it go faster
That is not all you said. You very clearly and emphatically said far more than that. And what you actually did say is utterly wrong!
.... he cannot gaurantee his multicore system will split the Perl threads between cores..
Remove the word "Perl" from that sentence and you have something that can be said about any kernel threads, regardless of source language or OS. This is NOT a limitation of Perls ithreads.
Or of threading. The exact (corrected) statement can be made about processes (forking) also. All that preemptive multitasking and kernel threading guarentees is that if there is a core available and a thread ready to run, then that thread will run on that core. Regardless of whether that thread is a part of a process that already has another thread running on another core.
In other words, your sentence is meaningless.
in all likelyhood, it will be run in the same core,
This statement is so wrong, so cockeyed; that it almost defies refutation.
Wrong! There is no way to draw any such conclusion in isolation. Which core of a multi-core system any given thread will run next is entirely dependant upon what else is running on the system; and what their current run states are.
meaning both his threads will share a single execution pointer..... the pointer can't be in 2 places at the same time
Again, utterly, completely wrong. Even on a single core system, each thread has its own EXECUTION POINTER--and STACK POINTER; and BASE POINTER; and every other register! When the kernel executes a context switch; it saves a complete copy of the current threads execution context, and restores that of the next thread chosen to run.
In a multi-core system, each core will be populated with the execution context of one of the threads currently eligable to run.
...if you have a code snippet that shows you how to force a Perl process to split it's execution across multiple cores, i would like to see it.... i could learn something
There is simply no need to "force a Perl process to split it's execution across multiple cores". It happens whether you like it or not. Indeed, the only way to prevent it is to set the Affinity mask, and that is not trivially available to Perl.
..... i don't know how many times this has been argued.... but Perl threads actually slow you down on a single cpu machine...
Again you make a completely meaningless sweeping generalisation. It really depends what you are doing.
This takes 10 seconds to run:
c:\test>perl -e"$t=time; sleep 5; sleep 5; print time - $t"
10
Whereas this only takes 5 seconds:
c:\test>perl -Mthreads -e"$t=time;async{sleep 5}->detach;sleep 5;print
+ time-$t"
5
If those sleeps represent any IO-bound processing, the result is a speedup even on a single-core system.
but i'm just advising him
Wrongly! Grossly and blatently
.. Perl Threads and multi-core CPUs discusses the pitfalls
And you apparently do not understand the discussion.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |