[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


1.2 Overview of Threads

A thread is a single, sequential flow of control within a program. Within each thread, there is a single point of execution. Most traditional programs consist of a single thread. Figure 1-1 and Figure 1-2 show the differences between a single threaded process and a multithreaded process.

Figure 1-1 Single Threaded Process

Using DECthreads, Digital's multithreading run-time library, a programmer can create several threads within a program. Threads execute concurrently, and, within a multithreaded program, there are at any time multiple points of execution. Threads execute within (and share) a single address space. Therefore, threads read and write the same memory locations. Synchronization elements such as mutexes and condition variables ensure that the shared memory is accessed correctly. DECthreads provides routines that allow you to create and use these synchronization elements. Mutexes and condition variables are discussed in Section 2.3.1 and Section 2.3.2.

Figure 1-2 Multithreaded Process

In Figure 1-2, notice that multiple threads share heap storage, static storage, and code but that each thread has its own register set and stack.

DECthreads provides the following four separate application programming interfaces (APIs) with which you can perform multithreaded operations:



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]