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

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

P: n/a
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+
3 Replies


P: n/a
On Mon, 07 Nov 2005 06:01:56 -0800, nrhayyal wrote:
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
Nov 7 '05 #2

P: n/a
Hello,

On Mon, 7 Nov 2005 14:01:56 UTC, "nrhayyal" <na************@satyam.com> wrote:
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
Nov 8 '05 #3

P: 2
Hello,

On Mon, 7 Nov 2005 14:01:56 UTC, "nrhayyal" <nagaraj_hayyal@satyam.com> wrote:
[color=blue]
> 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 ?[/color]

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

My last experience with AIX was 4.2. I can't help with this.
[color=blue]
> 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.[/color]

Of course it could work.

It could coredump if you had incorrect programming.

Yes.
[color=blue]
> how is the ratio mapped?[/color]

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.
[color=blue]
> how will the scheduler behave in this case?[/color]

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.
[color=blue]
> please help me in resolving my issues.[/color]

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?
[color=blue]
> thanks in advance to all the experts for their opinion.
>
>
> Regards
> Nagaraj Hayyal.[/color]

David
thanks david,
this means its not the programming issue, instead its the OS issue which OS will Take care of that.
program can only instruct the OS, but cant force the OS on how to do the job.
i guess i am right in what i am saying.
........

Nagaraj
Nov 8 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.