Types of Threads
All threads aren’t the same.
Figure 200 shows a program with three threads.
Assume that all 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. In TotalView, the definition of a user thread is simply a unit of execution created by a program.
Because the program creates user threads to do its work, they are also called worker threads.
Other threads can also be executing. For example, there are always threads that are part of the operating environment. These threads are called
manager threads. Manager threads exist to help your program get its work done. In
Figure 201, the horizontal threads at the bottom are user-created manager threads.
All threads are not created equal, and all threads do not execute equally. Many programs also create manager-like threads. Since these user-created manager threads perform services for other threads, they are called
service threads,
Figure 202.
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.
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
Figure 202 shows five threads, most of your debugging effort will focus on just two threads.