Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.

Slides:



Advertisements
Similar presentations
OPERATING SYSTEMS Threads
Advertisements

Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows.
Chap 4 Multithreaded Programming. Thread A thread is a basic unit of CPU utilization It comprises a thread ID, a program counter, a register set and a.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
Threads. Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 6: Threads Chapter 4.
Chapter 4: Multithreaded Programming
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 7 Chapter 4: Threads (cont)
Chapter 4: Multithreaded Programming
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
4.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 4 Multithreaded Programming Objectives Objectives To introduce a notion of.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 4: Threads.
02/02/2004CSCI 315 Operating Systems Design1 Threads Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads READ 4.1 & 4.2 NOT RESPONSIBLE FOR 4.3 &
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Chapter 4: Threads Adapted to COP4610 by Robert van Engelen.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Chapter 4: Threads. 4.2CSCI 380 Operating Systems Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Chapter 4: Multithreaded Programming. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Multithreaded Programming Overview.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 4 Operating Systems.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 4: Threads CS 170 T Yang, Sept 2012.
Chapter 4: Threads. 4.2 Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Threads A thread (or lightweight process) is a basic unit of CPU.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
CHAPTER 5: THREADS ( 线程 ) Overview Overview Multithreading Models (多线程模型) Multithreading Models (多线程模型) Thread Implementation Issues (线程实现事项) Thread Implementation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Multithreading Models Threading Issues Pthreads Solaris 2 Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 4: Threads Modified from the slides of the text book. TY, Sept 2010.
Chapter 4: Threads.
Chapter 4: Multithreaded Programming. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts What is Thread “Thread is a part of a program.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition, Chapter 4: Multithreaded Programming.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Lecture 3 Threads Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Silberschatz, Galvin and Gagne ©2013Operating System Concepts – 9 th Edition Chapter 4: Threads Modified.
Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads (7 th Edition)
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
CMSC 421 Spring 2004 Section 0202 Part II: Process Management Chapter 5 Threads.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
Chapter 4: Threads.
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 4: Threads.
Chapter 4: Threads.
Chapter 4: Threads.
OPERATING SYSTEMS Threads
Chapter 4: Threads.
Chapter 4: Threads.
CHAPTER 4:THreads Bashair Al-harthi OPERATING SYSTEM
Chapter 4: Threads.
Chapter 4: Threads.
Chapter 4: Threads.
Presentation transcript:

Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads

4.2 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Motivation Most modern applications are multithreaded Threads run within application Multiple tasks with the application can be implemented by separate threads Update display Fetch data Spell checking Answer a network request Process creation is heavy-weight while thread creation is light-weight Can simplify code, increase efficiency Kernels are generally multithreaded

4.3 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Multithreaded Server Architecture

4.4 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Benefits Responsiveness – may allow continued execution if part of process is blocked, especially important for user interfaces Resource Sharing – threads share resources of process, easier than shared memory or message passing Economy – cheaper than process creation, thread switching lower overhead than context switching Scalability – process can take advantage of multiprocessor architectures

4.5 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.6 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.7 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.8 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.9 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.10 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.11 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.12 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.13 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.14 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.15 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.16 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.17 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.18 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.19 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.20 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition User Threads and Kernel Threads User threads - management done by user-level threads library Three primary thread libraries: POSIX Pthreads Windows threads Java threads Kernel threads - Supported by the Kernel Examples – virtually all general purpose operating systems, including: Windows Solaris Linux Tru64 UNIX Mac OS X

4.21 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.22 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.23 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.24 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.25 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.26 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.27 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.28 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.29 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.30 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Multithreading Models Many-to-One One-to-One Many-to-Many

4.31 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.32 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.33 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.34 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.35 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.36 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.37 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.38 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition

4.39 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Threading Issues Semantics of fork() and exec() system calls Signal handling Synchronous and asynchronous Thread cancellation of target thread Asynchronous or deferred Thread-local storage Scheduler Activations

4.40 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Signal Handling Signals are used in UNIX systems to notify a process that a particular event has occurred. A signal handler is used to process signals  Signal is generated by particular event  Signal is delivered to a process  Signal is handled by one of two signal handlers:  default  user-defined Every signal has default handler that kernel runs when handling signal User-defined signal handler can override default For single-threaded, signal delivered to process

4.41 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Signal Handling (Cont.) Where should a signal be delivered for multi-threaded? Deliver the signal to the thread to which the signal applies Deliver the signal to every thread in the process Deliver the signal to certain threads in the process Assign a specific thread to receive all signals for the process

4.42 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Linux Threads Linux refers to them as tasks rather than threads Thread creation is done through clone() system call clone() allows a child task to share the address space of the parent task (process) Flags control behavior n struct task_struct points to process data structures (shared or unique)

Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition End of Chapter 4