Click to See Complete Forum and Search --> : Question about Threads and CPU's...


JMS
June 3rd, 2002, 02:34 PM
Question about Threads. I'm programming on a quad processor solaris box. My question is how do my cpu's get scheduled? Are they scheduled by process or by thread.

Meaning when I'm running a single multithreaded process does my program take advantage of the multi processors? Or do I need to run multi-processes to saturate these cpu's?

cup
June 25th, 2002, 03:44 AM
It is one processor per process. Threads are meant to be light-weight (LWP) so they all share the same processor.

JMS
June 25th, 2002, 11:48 AM
I actually asked this question quite some time ago. During off line research this is what I discovered.

Solaris has what is called kernel level threads which are scheduled across cpu's depending upon what activity is being done on the box. The os itself will try to optimize this, so if you've got four processors and four processes cross execution on the processors wont occur, but if you have one process with many threads the scheduler is likely to cross execute. Linux also has kernel level threads.

HP/UX does not have kernel level threads and I was not able to determine conclusively one way or the other about NT.

So it depends on the OS if threads in the same process are executed on different processors.

cup
June 25th, 2002, 12:19 PM
That's strange: when I was running a huge multi-threaded process, only one processor was used. All the others stayed idle. This happened on both Solaris 2.6 and HPUX 11. Things may have changed since I last looked at it (2000) :)

JMS
June 25th, 2002, 01:36 PM
Hp-ux that's what I've found too. But 2.6 should have spead the load out. I'll try to dig up my documentation on this. I wouldn't mind learning I've been informed incorrectly on this.

How did you determine your other cpu's were not involved in solaris?

cup
June 26th, 2002, 12:44 AM
No documentation to back this up. I just looked at the processor graphs. There was a command to let you see what each processor was doing but I can't remember what it is since I haven't used multi-processor Suns for some time. Whenever I ran a multi-threaded program, one processor would shoot up but the others just remained flat.