Download presentation
Presentation is loading. Please wait.
Published byLogan Eaton Modified over 8 years ago
1
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads
2
4.2 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 4: Threads Overview Motivation Benefits
3
4.3 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems.
4
4.4 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Overview A thread is a basic unit of CPU utilization (i.e. It is the smallest sequence of programmed instructions that can be managed independently) Thread comprises : ID, a program counter, a register set and a stack. It shares with other threads belonging to the same process its code section, data section and other operating system resources. A traditional (or heavyweight) process has a single thread of control. A thread could be considered a ‘lightweight’ process If a process has multiple threads of control, it can perform more than one task at a time. Threads provide a way to improve application performance through parallelism. Each thread belongs to exactly one process and no thread can exist outside a process.
5
4.5 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Single and Multithreaded Processes Traditional ( heavyweight ) process has a single thread of control - There is one program counter, and one sequence of instructions that can be carried out at any given time. Multi-threaded applications have multiple threads within a single process, each having their own program counter, stack and set of registers, but sharing common code, data, and certain structures such as open files.
6
4.6 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Motivation Many software packages that run on modern desktop PCs are multithreaded. An application typically is implemented as a separate process with several threads of control. Examples : E.G. (1) : A word processor may have a thread for displaying graphics, another thread for responding to keystrokes from the user, and a third thread for performing spelling and grammar checking in the background. E.G. (2) : A web server - Multiple threads allow for multiple requests to be satisfied simultaneously, without having to service requests sequentially or to fork off separate processes for every incoming request….(creating a new thread belongs to an existing process is less overhead of creating a new process) Most operating system kernels are now multithreaded >>>> several threads operate in the kernel, and each thread performs a specific task, such as managing devices or interrupt handling.
7
4.7 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Benefits There are four major categories of benefits to multi-threading: Responsiveness - One thread may provide rapid response while other threads are blocked or slowed down doing intensive calculations. Resource sharing – Processes may only share resources through techniques (e.g. shared memory or message passing) …Such techniques must be explicitly arranged by the programmer. By default threads share common code, data, and other resources, which allows multiple tasks to be performed simultaneously in a single address space.
8
4.8 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Benefits (Cont.) Economy - Creating and managing threads is much faster than performing the same tasks for processes. Scalability The benefits of multithreading can be greatly increased in a multiprocessor architecture, where threads may be running in parallel on different processors. A single-threaded process can only run on one processor, regardless how many CPUs are available. whereas the execution of a multi-threaded application may be split amongst available processors. …….( Note that single threaded processes can still benefit from multi-processor architectures when there are multiple processes contending for the CPU)
9
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition End of Chapter 4
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.