Thread: what the hell is that ??

  1. #31
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I believe svchost comprises nearly 300 separate threads/processes in XP and almost double that in Vista. I have no data yet for Windows 7. Not sure what the ratio of processes to threads is or more simply how many actual processes there are as opposed to threads spun off by the processes.

  2. #32
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> I believe svchost comprises nearly 300 separate threads/processes in XP and almost double that in Vista.

    Are you serious? That's crazy. What a waste of resources!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #33
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by Sebastiani View Post
    >> I believe svchost comprises nearly 300 separate threads/processes in XP and almost double that in Vista.

    Are you serious? That's crazy. What a waste of resources!
    My Build 7000 version of Windows 7 had ~215 threads across 11 processes. That's about how many threads my entire Linux system has...
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  4. #34
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    You must remember that svchost.exe is a specialized service for hosting processes that run of DLLs, Sebastiani. The fact that these services run under the same process actually conserves memory and optimizes its use. The disadvantage is that if any of these services crashes, the entire svchost process that is hosting that service is almost certainly going down, taking all the other services with it.

    If you go to HKLM\SYSTEM\CurrentControlSet\Services, you'll get a list of installed services. Clicking on each may reveal a key called ImagePath. If that key points to svchost.exe, that's a service that is going to be hosted by this process.

    Meanwhile, you can run a command line and type tasklist /svc. This will let you know which services are being used by each of the svchost processes you are currently seeing in your task manager. You can also go to HKLM\Software\Microsoft\Windows NT\CurrentVersion\Svchost. This is where the services groupings are described.

    Finally, the Process Explorer from Sysinternals will give you all the details about each svchost process, including the individual services and total number of threads.

    EDIT: Currently I'm running 129 threads on 7 svchost images (or groups, or processes , or whatchacallit) hosting 31 services. Seems pretty decent to me. As some of these services wake up from idle time, I'd expect the number of threads to climb considerably. I believe Bubba means the potential of threads/processes. Not an actual constant number across a normal windows session.
    Last edited by Mario F.; 07-08-2009 at 06:40 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #35
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    This is why they made the Vista defragmenter show you almost nothing while it works. Too many people asking stupid questions.
    Process Explorer FTW!

  6. #36
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by brewbuck View Post
    Windows runs services inside host processes which are called, creatively, "svchost.exe." It can run more than one service in a single process, although it doesn't always. It is impossible to kill svchost.exe because that is not the proper way to terminate a service -- you terminate services using the control panel administrative plugin, or by the "net stop" command on the command line.
    Ah, here's something even more funny.
    If you kill svchost.exe, at least on XP, you will initiate an automatic reboot due to critical system services having been stopped.
    I believe in Vista and forward, Windows can recover from it. Nevertheless, if you kill them, they will just restart.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #37
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> You must remember that svchost.exe is a specialized service for hosting processes that run of DLLs, Sebastiani. The fact that these services run under the same process actually conserves memory and optimizes its use.

    I know, I was merely shocked at the actual number of threads that it was running. I use Windows 2000, and the total number of svhost threads number less than 25! In fact, my entire system at this very moment has less than 115 threads executing *total*. I guess it's possible that newer versions of Windows have simply broken these down further to make things more efficient, but from my experience, at least, more threads != more efficiency, generally (there are exceptions, of course). Or perhaps the significant increase in threads is due to a dramatic increase in functionality, but from what I've seen with XP and Vista, aside from some of the more advanced graphics, I really don't see much of an improvement in that area to warrant such an increase in threads, IMO. Having said that, I always keep the number of services that run at a minimum, so I suspect that the default is much higher than the numbers I posted. And as far as Systernals goes, I've been using their products for a number of years, and in fact Process Explorer *is* my task manager.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #38
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> If you kill svchost.exe, at least on XP, you will initiate an automatic reboot due to critical system services having been stopped.

    That's true of Win2K, as well. I suspect it has something to do with the fact that Windows uses the RPC mechanism internally and so literally cannot run without it.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #39
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Yes I was not indicating that there are always a set number of threads running, however, the potential for a great number does exist and your task manager won't show them as anything but an instance of svchost. This is quite deceptive. So when you see that you have 40 processes running in task manager keep in mind the actual number lurking behind those svchost instances is considerably more.

    Usually when your system is sluggish or erratic and yet you cannot see anything in task manager that is causing it I would suspect it's one of the processes/threads being hosted by svchost. I really did not understand svchost till a friend of mine at Microsoft explained exactly what it was. I know that Vista at least has the potential to spawn off twice as many processes/threads through svchost as XP does. This is one of the many reasons that Vista is so slow. Also if you have a bunch of developers thinking they can just use svchost to host their process it quickly becomes abused and over-used and you end up having far more being hosted than is necessary. So if the system is extremely sluggish and unresponsive this is the first place I would look for the answer. I've also heard that many of these probably use DDE which could hamper performance even more.

    In short it started out as a great idea and has many benefits as Mario pointed out but it has been turned into a bit of a mess. The biggest issue is most certainly what Mario again pointed out. If any of the processes/threads crash that the svchost instance is hosting it is entirely possible your system will come crashing down as well since that svchost is more than likely hosting far more than just the offending process or thread.

    I have never programmed anything that actually uses svchost so my experience with it is pretty much limited to what I've been told firsthand and what I've read about it on the internet. Microsoft does have a tool to view all current threads and processes but it does not make clear which ones belong to which instances of svchost. However it can give you a better picture of your system.
    Last edited by VirtualAce; 07-10-2009 at 04:51 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What the hell!? Crashes and memory leaks?
    By pobri19 in forum C++ Programming
    Replies: 3
    Last Post: 09-26-2008, 05:45 AM
  2. operator from hell
    By algi in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 12-24-2004, 07:36 AM
  3. DLL Hell
    By Sentaku senshi in forum Windows Programming
    Replies: 9
    Last Post: 11-21-2002, 08:06 AM
  4. Living in the 00'S
    By mithrandir in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-21-2002, 09:31 AM
  5. Heaven, Hell, and Aetheists/Non-believers
    By Aran in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 09-10-2001, 02:18 PM