Connecting Tech Pros Worldwide Forums | Help | Site Map

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

nrhayyal
Guest
 
Posts: n/a
#1: Nov 7 '05
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.


Victor Bazarov
Guest
 
Posts: n/a
#2: Nov 7 '05

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


On Mon, 07 Nov 2005 06:01:56 -0800, nrhayyal wrote:[color=blue]
> Hi All,
> thanks for reading this post.
> just wanted to know about the ratio of threads and processors.
> [..][/color]

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
David
Guest
 
Posts: n/a
#3: Nov 8 '05

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


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
Newbie
 
Join Date: Nov 2005
Posts: 2
#4: Nov 8 '05

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


Quote:

Originally Posted by David

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
Closed Thread