Thursday, August 13, 2015

Threads and handles explained

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.

Source : A techie (harry) explained in http://www.certforums.com/

No comments:

Post a Comment