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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Multi threading with one processor??

Multi threading with one processor??

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 5 Posters 0 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.
  • B Offline
    B Offline
    boon kian
    wrote on last edited by
    #1

    Hi I am writing a program to process multiple independent datas. This program is very processing intensive. So i am wondering if multi threading would help to reduce the amount of processing time. I have doubts over it because I have only one processor. So wouldn't the time taken for the processing to be the same in multithreading case (or even more due to addition overhead)?? If it helps to cut down the time taken, how does it do it with only one processor?? Can someone please enlighten me ?? Thank you very much for the kind attention !!

    J M N T 4 Replies Last reply
    0
    • B boon kian

      Hi I am writing a program to process multiple independent datas. This program is very processing intensive. So i am wondering if multi threading would help to reduce the amount of processing time. I have doubts over it because I have only one processor. So wouldn't the time taken for the processing to be the same in multithreading case (or even more due to addition overhead)?? If it helps to cut down the time taken, how does it do it with only one processor?? Can someone please enlighten me ?? Thank you very much for the kind attention !!

      J Offline
      J Offline
      jhwurmbach
      wrote on last edited by
      #2

      boon kian wrote: So wouldn't the time taken for the processing to be the same Maybe, but your App stays responsive.


      My opinions may have changed, but not the fact that I am right.

      1 Reply Last reply
      0
      • B boon kian

        Hi I am writing a program to process multiple independent datas. This program is very processing intensive. So i am wondering if multi threading would help to reduce the amount of processing time. I have doubts over it because I have only one processor. So wouldn't the time taken for the processing to be the same in multithreading case (or even more due to addition overhead)?? If it helps to cut down the time taken, how does it do it with only one processor?? Can someone please enlighten me ?? Thank you very much for the kind attention !!

        M Offline
        M Offline
        Mike Nordell
        wrote on last edited by
        #3

        boon kian wrote: So i am wondering if multi threading would help to reduce the amount of processing time. Not using a single CPU. Quite the opposite; the overhead will make the processing slower. If the process is e.g. I/O bound the percieved speed of the application might benefit greatly from multithreading, but the total CPU time used will always be greater for a multithreading program than a singlethreded program (even if by such a small amount of time that one wouldn't even bother to try measure it).

        1 Reply Last reply
        0
        • B boon kian

          Hi I am writing a program to process multiple independent datas. This program is very processing intensive. So i am wondering if multi threading would help to reduce the amount of processing time. I have doubts over it because I have only one processor. So wouldn't the time taken for the processing to be the same in multithreading case (or even more due to addition overhead)?? If it helps to cut down the time taken, how does it do it with only one processor?? Can someone please enlighten me ?? Thank you very much for the kind attention !!

          N Offline
          N Offline
          Nitron
          wrote on last edited by
          #4

          I agree with the above posts, but there are some things you may want to consider... First, the user usually despises apps that appear "frozen" and unresponsive. If you go calling a time-consuming data reduction function from the main UI thread, your app will appear to "hang" during processing. If you don't pump update messages and redraw the screen, the user can slide another window over your app, and your app will just appear blank and dead. However, don't go off spawning 20 threads to process your stuff either! I would definately consider putting the data reduction algorithms in a seperate "worker" thread, and pumping progress messages from within it. Although you won't gain any speed (or may actually lose some), it is most likely in the best interest of the user. This will keep your UI happy and responsive, and the world will be a better place :rolleyes: - Nitron


          "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

          1 Reply Last reply
          0
          • B boon kian

            Hi I am writing a program to process multiple independent datas. This program is very processing intensive. So i am wondering if multi threading would help to reduce the amount of processing time. I have doubts over it because I have only one processor. So wouldn't the time taken for the processing to be the same in multithreading case (or even more due to addition overhead)?? If it helps to cut down the time taken, how does it do it with only one processor?? Can someone please enlighten me ?? Thank you very much for the kind attention !!

            T Offline
            T Offline
            Ted Ferenc
            wrote on last edited by
            #5

            As has already been mentioned it could be slower, but you will find that the single CPU will be running at 100% all the time, whereas a single threaded app could be waiting for some input/event whilst trying to process the data. If the data does lend it's self to multithreading then do it, you never know you may get a multi cpu machine, I do have a 2 cpu machine, but be careful as there could be an interaction between processing data on each of the cpu's that could cause the prog to hang/crash


            If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

            N 1 Reply Last reply
            0
            • T Ted Ferenc

              As has already been mentioned it could be slower, but you will find that the single CPU will be running at 100% all the time, whereas a single threaded app could be waiting for some input/event whilst trying to process the data. If the data does lend it's self to multithreading then do it, you never know you may get a multi cpu machine, I do have a 2 cpu machine, but be careful as there could be an interaction between processing data on each of the cpu's that could cause the prog to hang/crash


              If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

              N Offline
              N Offline
              Nitron
              wrote on last edited by
              #6

              Ted Ferenc wrote: whereas a single threaded app could be waiting for some input/event whilst trying to process the data. umm, don't you mean a multi-threaded app? :~ A single thread will cycle through the processing algorithm and not return until complete. The multi-threaded app can process the data AND recieve messages from the user. - Nitron


              "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

              T 1 Reply Last reply
              0
              • N Nitron

                Ted Ferenc wrote: whereas a single threaded app could be waiting for some input/event whilst trying to process the data. umm, don't you mean a multi-threaded app? :~ A single thread will cycle through the processing algorithm and not return until complete. The multi-threaded app can process the data AND recieve messages from the user. - Nitron


                "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

                T Offline
                T Offline
                Ted Ferenc
                wrote on last edited by
                #7

                What as I was trying to say was on a single CPU machine, multithreaded, the CPU usage will probably be 100% but if only one thread is used it could end up waiting for some event therefore it will not use 100% CPU time, but there is an overhead of course. But if multithreaded the likelyhood is that one thread may be waiting but another should be processing. I fink my grammer was not correct, sorry:confused:


                If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

                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