This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 1 CMP 426 & 697 (Operating Systems) Additional Reference on Multi-threading models and implementations in various Operating Systems References W. Stalling, Operating Systems: Internals and Design Principles , 7 th edition, Prentice-Hall, 2012. F. Zabatta and K. Ying, ―Thread Performance Comparison: Windows NT and Solaris‖, in the Proceedings of the 2 nd USENIX Windows NT Symposium, pp. 57-pp. 66 NPTL Optimization , Sam-Sung Embedded Systems Group, 2010. Wikis about multithreading and POSIX (Portable Operating System Interface for Unix) thread specification 1. Introduction 1.1. Multithreading Multithreading refers to the ability of an OS to support multiple, concurrent paths of execution within a single process. To distinguish processes from threads, the unit of scheduling and dispatching is usually referred to as a thread (or termed lightweight process), while the unit of resource ownership is usually referred to as a process (or task) . In a multithreaded environment, a process is defined as the unit of resource allocation and a unit of protection. The following are associated with processes (process context): • A virtual address space that holds the process image (code, data, stack, heap) • Protected access to processors and possibly to other processes (for inter-process communications), files, and I/O resources (devices and channels such as DMAs) Within a process, there may be one or more threads, each with the following (thread context) • A thread execution state (Running, Ready, etc.) • A saved thread context when not running; one way to view a thread is as an independent program counter operating within a process • An execution stack • Some per-thread static storage for local variables • Access to the memory and resources of its process, shared with all other threads in that process (global data) 2 Figure 1.1: Process vs. Thread In a multithreaded environment, there is still a single process control block and user address space associated with the process, but now there are separate stacks for each thread, as well as a separate control block for each thread containing register values, priority, and other thread-related state information. In an OS that supports threads, scheduling and dispatching is done on a thread basis; hence, most of the state information dealing with execution is maintained in thread-level data structures. There are, however, several actions that affect all of the threads in a process and that the OS must manage at the process level. For example, suspension involves swapping the address space of one process out of main memory to make room for the address space of another process. Because all threads in a process share the same address space, all threads are suspended at the same time. Similarly, termination of a process terminates all threads within that process....
View Full Document
- Spring '12