In a multithreaded application,should processors be equal to no of threads?

N

nrhayyal

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.
 
V

Victor Bazarov

Hi All,
thanks for reading this post.
just wanted to know about the ratio of threads and processors.
[..]

You're totally OT here, sorry. Try comp.programming.threads. Or the
newsgroup for your OS.

Just so you know, C++ does not care about processors and its execution
model _presumes_ no threading. At this point, anyway.

V
 
D

David

Hello,

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 ?

Not unless you have extremely compute intensive tasks that will never
block or wait on anything.
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?

My last experience with AIX was 4.2. I can't help with this.
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.

Of course it could work.

It could coredump if you had incorrect programming.

Yes.
how is the ratio mapped?

Unknown. See your operating system's task sceduler documentation
and all of the parameters you have set for your system, and all
tasks in the system.
how will the scheduler behave in this case?

It is supposed to make the best effort with what hardwaare it has.
A single CPU can generally keep dozens, or more, extremely compute
intensive tasks working most of the time.
please help me in resolving my issues.

I have no idea what you are worried about. You seem to be
over optimizing the thread/process utilization of your system.
It is truely that busy?
thanks in advance to all the experts for their opinion.


Regards
Nagaraj Hayyal.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top