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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nrhayyal

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

    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,sho uld 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_se tscope(&tattr,P THREAD_SCOPE_SY STEM);


    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

    #2
    Re: In a multithreaded application,sho uld 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.programmin g.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

    Comment

    • David

      #3
      Re: In a multithreaded application,sho uld 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,sho uld 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_se tscope(&tattr,P THREAD_SCOPE_SY STEM);
      >
      >
      > 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

      Comment

      • nagaraj_hayyal
        New Member
        • Nov 2005
        • 2

        #4
        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,sho uld 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_se tscope(&tattr,P THREAD_SCOPE_SY STEM);
        >
        >
        > 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

        Comment

        Working...