Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Threads Handling

Threads Handling

Scheduled Pinned Locked Moved C / C++ / MFC
question
28 Posts 18 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U User 4113829

    Hi, Can anyone let me know how many threads can be run at a given point of time? Ranjini

    modified on Monday, February 04, 2008 7:56:19 AM

    J Offline
    J Offline
    James R Twine
    wrote on last edited by
    #14

    Meaning the total number of threads that the OS can support, or the total number of threads that your app can launch successfully? I believe that the former is limited by the amount of resources available to the OS (having 4GB installed means nothing if only 256MB are used internally by the OS).    The latter is limited much the same, except that it also gains a limitation from the application itself.  Since a thread's stack space comes from the address space of the process, you can create enough threads that you run out of available thread space.  You can do the same thing by creating threads without cleaning them up (or closing their handles) - the address space used by the thread will not get recovered, and even though you have memory available, you have "no place to put it."    Peace!

    -=- James
    Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
    Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
    See DeleteFXPFiles

    U 1 Reply Last reply
    0
    • U User 4113829

      Hi, Can anyone let me know how many threads can be run at a given point of time? Ranjini

      modified on Monday, February 04, 2008 7:56:19 AM

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #15

      And also it cannot cross one more limit, the numbers that can uniquely represented by the Value of HANDLE, Say HANDLE is a 32 bit value, then 2 power 32 is the limit as each thread is represented by a HANDLE. :)

      C L 2 Replies Last reply
      0
      • R Rajkumar R

        And also it cannot cross one more limit, the numbers that can uniquely represented by the Value of HANDLE, Say HANDLE is a 32 bit value, then 2 power 32 is the limit as each thread is represented by a HANDLE. :)

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #16

        Are you kidding?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        [my articles]

        R 1 Reply Last reply
        0
        • C CPallini

          Are you kidding?

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          [my articles]

          R Offline
          R Offline
          Rajkumar R
          wrote on last edited by
          #17

          I was, I am not sure, but since thread is represented by HANDLE, the number of threads also depends on this data Isn't it? I agree hardware resource will retrict. but assume if infinite hardware, then comment on the above

          C 1 Reply Last reply
          0
          • R Rajkumar R

            I was, I am not sure, but since thread is represented by HANDLE, the number of threads also depends on this data Isn't it? I agree hardware resource will retrict. but assume if infinite hardware, then comment on the above

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #18

            Rajkumar R wrote:

            I am not sure, but since thread is represented by HANDLE, the number of threads also depends on this data Isn't it?

            Of course.

            Rajkumar R wrote:

            I agree hardware resource will retrict. but assume if infinite hardware, then comment on the above

            Assuming infinite hardware, you may have even a bigger number of thread, since HANDLE definition is

            typedef PVOID HANDLE;

            i.e. architecture dependent. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            [my articles]

            R 1 Reply Last reply
            0
            • C CPallini

              Rajkumar R wrote:

              I am not sure, but since thread is represented by HANDLE, the number of threads also depends on this data Isn't it?

              Of course.

              Rajkumar R wrote:

              I agree hardware resource will retrict. but assume if infinite hardware, then comment on the above

              Assuming infinite hardware, you may have even a bigger number of thread, since HANDLE definition is

              typedef PVOID HANDLE;

              i.e. architecture dependent. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              [my articles]

              R Offline
              R Offline
              Rajkumar R
              wrote on last edited by
              #19

              Yes, I mean even if we have enough h/w resource (not infinite) that can run more than 2 power 32 threads (I think this is possible, what do you say?) on machine in which PVOID is 32 bit, the HANDLE is restricting isn't? :)

              C 1 Reply Last reply
              0
              • R Rajkumar R

                Yes, I mean even if we have enough h/w resource (not infinite) that can run more than 2 power 32 threads (I think this is possible, what do you say?) on machine in which PVOID is 32 bit, the HANDLE is restricting isn't? :)

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #20

                Well, on such a machine, a kind of thread-handle-bank-switching will be required! (i.e. the revenge of the INTEL 16 bit architecture) :laugh:

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                [my articles]

                R 1 Reply Last reply
                0
                • R Rajkumar R

                  And also it cannot cross one more limit, the numbers that can uniquely represented by the Value of HANDLE, Say HANDLE is a 32 bit value, then 2 power 32 is the limit as each thread is represented by a HANDLE. :)

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #21

                  Rajkumar R wrote:

                  HANDLE is a 32 bit value, then 2 power 32 is the limit as each thread is represented by a HANDLE

                  Thread HANDLEs and many other kernel object HANDLEs are always a multiple of 4 because the last two bits of the HANDLE are always zero. The last two low order bits can be used as TAG bits. Best Wishes, -David Delaune

                  R 1 Reply Last reply
                  0
                  • C CPallini

                    Well, on such a machine, a kind of thread-handle-bank-switching will be required! (i.e. the revenge of the INTEL 16 bit architecture) :laugh:

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    [my articles]

                    R Offline
                    R Offline
                    Rajkumar R
                    wrote on last edited by
                    #22

                    thread handle bank also does have limit :-D only we can increase the limit :)

                    1 Reply Last reply
                    0
                    • L Lost User

                      Rajkumar R wrote:

                      HANDLE is a 32 bit value, then 2 power 32 is the limit as each thread is represented by a HANDLE

                      Thread HANDLEs and many other kernel object HANDLEs are always a multiple of 4 because the last two bits of the HANDLE are always zero. The last two low order bits can be used as TAG bits. Best Wishes, -David Delaune

                      R Offline
                      R Offline
                      Rajkumar R
                      wrote on last edited by
                      #23

                      so it is even less 2 power 30 :)

                      1 Reply Last reply
                      0
                      • U User 4113829

                        Hi, Can anyone let me know how many threads can be run at a given point of time? Ranjini

                        modified on Monday, February 04, 2008 7:56:19 AM

                        M Offline
                        M Offline
                        Mark Salsbery
                        wrote on last edited by
                        #24

                        One thread per processor is all the threads that can run at a given point of time. Mark

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        R 1 Reply Last reply
                        0
                        • M Mark Salsbery

                          One thread per processor is all the threads that can run at a given point of time. Mark

                          Mark Salsbery Microsoft MVP - Visual C++ :java:

                          R Offline
                          R Offline
                          Rajkumar R
                          wrote on last edited by
                          #25

                          It is not valid for HT (Hyper threading) machine, one processor multiple execution chain :)

                          M 1 Reply Last reply
                          0
                          • J James R Twine

                            Meaning the total number of threads that the OS can support, or the total number of threads that your app can launch successfully? I believe that the former is limited by the amount of resources available to the OS (having 4GB installed means nothing if only 256MB are used internally by the OS).    The latter is limited much the same, except that it also gains a limitation from the application itself.  Since a thread's stack space comes from the address space of the process, you can create enough threads that you run out of available thread space.  You can do the same thing by creating threads without cleaning them up (or closing their handles) - the address space used by the thread will not get recovered, and even though you have memory available, you have "no place to put it."    Peace!

                            -=- James
                            Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                            Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                            See DeleteFXPFiles

                            U Offline
                            U Offline
                            User 4113829
                            wrote on last edited by
                            #26

                            Hi, Firstly, Thanks for your reply. It is helpful. Yes I meant The total number of threads that my app can launch successfully. Say if I have 1,00,000 threads quequing up, will my app be able to handle it? Thanks in Advance Ranjini

                            M 1 Reply Last reply
                            0
                            • U User 4113829

                              Hi, Firstly, Thanks for your reply. It is helpful. Yes I meant The total number of threads that my app can launch successfully. Say if I have 1,00,000 threads quequing up, will my app be able to handle it? Thanks in Advance Ranjini

                              M Offline
                              M Offline
                              Maxwell Chen
                              wrote on last edited by
                              #27

                              Member 4116875 wrote:

                              Yes I meant The total number of threads that my app can launch successfully. Say if I have 1,00,000 threads quequing up, will my app be able to handle it?

                              You can have a try now! ;) (Remember that 1: 'suspended', 2: 'resumed' with WaitForXXObject, and 3: 'resumed' with Sleep(n) are different. )

                              Maxwell Chen

                              1 Reply Last reply
                              0
                              • R Rajkumar R

                                It is not valid for HT (Hyper threading) machine, one processor multiple execution chain :)

                                M Offline
                                M Offline
                                Mark Salsbery
                                wrote on last edited by
                                #28

                                Fine...I'll include logical processors in the list of processors as well ;P Mark

                                Mark Salsbery Microsoft MVP - Visual C++ :java:

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups