Types of Threads
All threads aren't the same. The following figure shows a program with three threads.
Assume that all of these threads are user threads; that is, they are threads that perform some activity that you've programmed.
Note: Many computer architectures have something called user mode, user space, or something similar. User threads means something else. The TotalView definition of a user thread is simply a unit of execution created by a program.
Because your program creates user threads to do the work of your program, they are also called worker threads.
Other threads can also be executing. For example, the threads that are part of the operating environment are manager threads. These are threads that your environment or operating system adds to your program to help it get work done. In the following two figures, the horizontal threads at the bottom are user-created manager threads.
All threads are not created equal and all threads do not execute equally. In most cases, a program also creates manager-like threads. Since these user-created manager threads perform services for other threads, they are called service threads.
These service threads are also worker threads. For example, the sole function of a user service thread might be to send data to a printer in response to a request from the other two threads.
One reason you need to know which of your threads are service threads is that a service thread performs different types of activities than your other threads. Because their activities are different, they are usually developed separately and, in many cases, are not involved with the fundamental problems being solved by the program. Here are two examples:
- The code that sends messages between processes is far different than the code that performs fast Fourier transforms. Its bugs are quite different than the bugs that create the data that is being transformed.
- A service thread that queues and dispatches messages sent from other threads might have bugs, but the bugs are different than the rest of your code and you can handle them separately from the bugs that occur in nonservice user threads.
In contrast, your user threads are the agents that perform the program's work. Being able to distinguish between the two kinds of threads means that you can focus on the threads and processes that actively participate in an activity, rather than on threads performing subordinate tasks.
Although this last figure shows five threads, most of your debugging effort will focus on just two threads.