By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,445 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,445 IT Pros & Developers. It's quick & easy.

Multi-threaded application - Should num of processors equal num of threads?

P: 2
Hi All,
thanks for reading this post.
just wanted to know about the ratio of threads and processors.
i am working on c++ on AIX5.2 platform.
my c++ program are multithreaded programs.


In a multithreaded application,should no of processors be equal to no of threads ?
if we set the thread_scope to system( meaning 1 kernel thread to 1
user thread), does that mean that processors should be equal or more
than the threads?
suppose if we set,
rc = pthread_attr_setscope(&tattr,PTHREAD_SCOPE_SYSTEM) ;


And if i have 4 processors and 7 threads running simultaneously in my
applications.
will that work? or will it cause coredump ? will other threads wait for


CPU.
how is the ratio mapped?
how will the scheduler behave in this case?
please help me in resolving my issues.
thanks in advance to all the experts for their opinion.


Regards
Nagaraj Hayyal.
Nov 7 '05 #1
Share this Question
Share on Google+
2 Replies


P: 62
Hi All,
thanks for reading this post.
just wanted to know about the ratio of threads and processors.
i am working on c++ on AIX5.2 platform.
my c++ program are multithreaded programs.


In a multithreaded application,should no of processors be equal to no of threads ?
if we set the thread_scope to system( meaning 1 kernel thread to 1
user thread), does that mean that processors should be equal or more
than the threads?
suppose if we set,
rc = pthread_attr_setscope(&tattr,PTHREAD_SCOPE_SYSTEM) ;


And if i have 4 processors and 7 threads running simultaneously in my
applications.
will that work? or will it cause coredump ? will other threads wait for


CPU.
how is the ratio mapped?
how will the scheduler behave in this case?
please help me in resolving my issues.
thanks in advance to all the experts for their opinion.


Regards
Nagaraj Hayyal.

it is always no of thread to num of processors bcos creating n threads without processors will end up in race or dead lock. u can have pools of threads but active threads eqaul to the proceesors number only
Aug 17 '07 #2

Expert 10K+
P: 11,448
it is always no of thread to num of processors bcos creating n threads without processors will end up in race or dead lock. u can have pools of threads but active threads eqaul to the proceesors number only
The last part is true, the first part isn't. When there are no processors available
at any moment in time a thread simply won't run but is scheduled as runnable.
It has nothing to do with deadlocks or race conditions. Even with a zillion cpus
and two threads deadlocks can occur.

kind regards,

Jos
Aug 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.