What does “threads” and “handles” in my PC’s task manager mean?

1.24K views

Whenever I open the task manager on my PC to check the status a few terms confuse me. I know what CPU, memory usage, and GHz mean, but I don’t understand “threads” and “handles”. I’ve searched online, but the explanations are too complicated. Can anyone help clear this up?

In: Technology

2 Answers

Anonymous 0 Comments

Lets say you have a single core CPU. It can only do one thing at a time. Yet you can still have multiple applications open, each doing their own thing at the same time. How is that possible?

Threads are the answer. Each application has its own “thread”, and the OS manages which thread is currently executing on the CPU. It can switch between these threads quickly enough that it appears as if all the programs are running at the same time.

Sometimes a single application wants to be able to do multiple things concurrently. So it’s possible for programs to spawn more threads. The “threads” count tells you how many it has.

Your CPU probably has more than 1 core, so it is possible to run more than 1 thread a time. But still, there are more threads than there are cores so it’s still necessary to have threads.

Handles are more generic. If an application needs to use a resource that’s managed by the OS it needs a handle to it so the OS can track what things each process is using. In this case handles could refer to threads, files, windows, all sorts of things. So the handle count doesn’t really tell you much specific.

Anonymous 0 Comments

A process is an instance of a computer program that is running on a computer. Processes are executed by units of work called threads. A process can have multiple threads.

A function of the operating system is to schedule threads. You see, you have only so many cores, so many execution units in your hardware, and if you’re running Windows, you can have hundreds or thousands of threads. So what has to happen is each thread gets a time slice in a core. The scheduler is responsible for getting threads into and out of a core for its time slice, in some orderly fashion. So a more technical definition for a thread is the smallest unit of work handled by the scheduler.

A handle is an abstract reference to a resource. A resource is any physical or virtual component of your computing environment with limited availability. Memory is a resource, and memory addresses are actually just handles. A mutex is a synchronization mechanism between different processes sharing a resource – for example, if you’re sharing memory, then you want to be sure that you don’t write over what some other process is in the middle of reading. When you open a file, you get a file handle referring to that open resource.

Often, from a program’s perspective, a handle is just some integer, the system enumerates resources. That handle refers to some internal table of data, some program state, that is managed by the operating system – that the resource is in use, and how.