Chien-Chung Shen CIS, UD cshen@cis.udel.edu Threads Chien-Chung Shen CIS, UD cshen@cis.udel.edu
Introduction All threads within a single process have access to the same process components, such as file descriptors and memory A typical UNIX process has a single thread of control: doing only one thing at a time With multiple threads of control, a single process can do more than one thing at a time Benefits of multithreading can be realized even if a program is running on a uniprocessor A program can be simplified using threads regardless of the number of processors, because the number of processors doesn’t affect the program structure As long as a program (?) has to block when serializing tasks, there are improvements in response time and throughput when running on a uniprocessor, because some threads might be able to run while others are blocked
Threads Each thread has an execution context, including thread ID, a set of register values, a stack, a scheduling priority, etc. Everything within a process is sharable among the threads, including the text of the executable program, program’s global and heap memory, stacks, and file descriptors pthread or POSIX thread