1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Handles,Threads in task manager

Discussion in 'A+' started by Dhughes, Jun 27, 2007.

  1. Dhughes

    Dhughes Byte Poster

    in the task manager in XP what are the Handles and threads that are quoted in the Totals box on the performance tab?
    Certifications: A+ Essentails, A+ Technician , MCDST
  2. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    When you start a program, that program runs as a 'process'. This is something that runs in its own protected area, with its own memory. Other processes can't touch that memory.

    Some times the program needs to do several things at once in a multitasking way, similar to the way the processes multitask. For example, a spreadsheet might recalculate cells as you are entering data. It *could* start another process, but they can't (easily) share memory, which it would need to if recalculating cells!

    So we need another sort of process that isn't quite so separated. This is a 'thread'. Threads live within processes, and share the same memory as other threads within that process.

    When a program opens a file, or wants to talk to the Internet it asks Windows to do this, and tells Windows what file etc is required. Windows does this, and hands back a token to the program to use in subsequent operations so that Windows can keep track of what is done. This token is called a 'handle' and basicaly is a (fairly) random 32bit number.

    Clearly Windows has to keep track of handles, processes and threads - they all take resources. So that part of the info-panel tells you just how many of these are in use.

    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  3. dmarsh

    dmarsh Terabyte Poster

    Well alot of stuff in computing is pretty well thought out, like the desktop metaphor for instance etc.

    A handle is something you use to hold onto something. Its the same on the computer its a token as described that relates to some system managed resource, think of what you do with your coat when you go to a nightclub, you get a ticket for you coat when you hand it in, the tickets like the handle. The main difference in windows is that generally the handle is used because the resources themself are never visisble, they are hidden from you. Its like those laboratory cabinets where you can only interact through a hole with special gloves !

    A thread is a lightweight process, i expect they called it a thread because, its an execution path through your program, so they are using the metaphor of a piece of string representing the path of execution and that there can be many paths. Think Handsel and Gretal. :) I prefer to think of them as circles normally because they tend to loop in most programs, in event driven programs you have an 'event loop' or often you have a background process like a daemon etc. Other threads are just one off background processes and are just kicked off and then die.

    Interprocess communiction and task switching are quite expensive operations, a processor context switch for a thread is less costly, and communication is cheaper because a shared memory model is used.

Share This Page