Re: is threading useful with a single CPU?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Fred Exley wrote:

Just trying to understand the basics here. If the OS has just one CPU,
what
advantage is there in threading? thanks

Hi Fred,

Threading is everywhere. It's not just a concept that's useful on two CPUs.

Take two applications, AppA and AppB. If you start these on your computer,
how can you switch between them? How can AppA calculate a list of prime
numbers, while AppB is calculating Pi to a million decimal places?

The answer is threading: Whenever you start a process, that process will
initially begin in one thread, and can then spawn more and more threads.
Going back to AppA and AppB, when you launch these two applications, AppA
will start it's thread and AppB will start it's thread. AppA's thread
contains code to calculate prime numbers and AppB's thread contains code to
calculate Pi. These two processes appear to run simultaneously, because
the operating system is scheduling the execution of each thread, and
allowing the thread to run.

Taking a much larger example, e.g. Microsoft Word, and Microsoft Visual
Studio. When you launch these applications, you can switch between them,
you can start VS compiling and you can write a document in Word. These
applications also create multiple threads, to do various tasks.

Multiple threads within a single process are used to execute code
simultaneously (or what appears to be simultaneously).

The following article will probably be of better use to you:

http://en.wikipedia.org/wiki/Thread_%28computer_science%29

--
Hope this helps,
Tom Spink
.



Relevant Pages

  • Assembly loaded from URL needs to read registry - but cant
    ... I have a set of applications that use a common assembly library. ... AppA, AppB and AppC all use LibA and LibB ...
    (microsoft.public.dotnet.security)
  • Re: Process & memory usage guru question
    ... As far as thread pools go, AppA has an item to process, it calls the ... CreateProcess to execute cmd.exe to start AppB. ... AppB launches pkzip. ...
    (microsoft.public.vc.mfc)
  • Re: Process & memory usage guru question
    ... AppB launches pkzip. ... I am still uncertain as to why AppA is exiting unexpectedly. ... CreateProcess() when you simply want to run pkzip to compress files. ...
    (microsoft.public.vc.mfc)
  • Re: Process & memory usage guru question
    ... I have been trying to use OH.exe that is available in the "Windows Resource ... There is ZERO chance that any memory problems in appB will have any effect on appA. ... To start the AppB app that does the zipping, we call one of our DLL ...
    (microsoft.public.vc.mfc)
  • Re: Pipe stderr and stdout
    ... I'd like to pipe stdout and stderr from appA to appB and appC (appB ...
    (comp.unix.shell)