T HREADS Gursharan Singh Tatla 27-Jan-11 1

Slides:



Advertisements
Similar presentations
Chapter 4 Threads Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Advertisements

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.
1 Chapter 5 Threads 2 Contents  Overview  Benefits  User and Kernel Threads  Multithreading Models  Solaris 2 Threads  Java Threads.
CHAPTER 5 THREADS & MULTITHREADING 1. Single and Multithreaded Processes 2.
Chapter 4: Multithreaded Programming
Chapter 5 Threads os5.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Course: Operating Systems Instructor: Umar Kalim NUST Institute of Information Technology, Pakistan Operating Systems.
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.
CS238 Lecture 5 Threads Dr. Alan R. Davis. Threads Definitions Benefits User and Kernel Threads Multithreading Models Solaris 2 Threads Java Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Based on Silberschatz, Galvin and Gagne  2009 Threads Definition and motivation Multithreading Models Threading Issues Examples.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Thread definitions and relationship to process Multithreading.
Process Concept An operating system executes a variety of programs
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
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.
9/13/20151 Threads ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original slides.
Operating System Principles Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Chapter 4: Threads. From Processes to Threads 4.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Threads.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Operating System Concepts Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
CHAPTER 5: THREADS ( 线程 ) Overview Overview Multithreading Models (多线程模型) Multithreading Models (多线程模型) Thread Implementation Issues (线程实现事项) Thread Implementation.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Multithreading Models Threading Issues Pthreads Solaris 2 Threads.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
Source: Operating System Concepts by Silberschatz, Galvin and Gagne.
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 Chapter 4: Threads Overview Multithreading Models Threading Issues.
Chapter 4: Threads. 2 Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads.
Overview Multithreading Models Threading Issues Pthreads Solaris 2 Threads Windows 2000 Threads Linux Threads Java Threads.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
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.
Multithreaded Programing. Outline Overview of threads Threads Multithreaded Models  Many-to-One  One-to-One  Many-to-Many Thread Libraries  Pthread.
Chapter 4: Multithreaded Programming. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts What is Thread “Thread is a part of a program.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th 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.
Department of Computer Science and Software Engineering
Lecture 3 Threads Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
1 OS Review Processes and Threads Chi Zhang
T HREADS Lecture 5 1 L. Mohammad R.Alkafagee. H EAVYWEIGHT - PROCESSES The cooperation of traditional processes also known as heavyweight processes which.
Saurav Karmakar. Chapter 4: Threads  Overview  Multithreading Models  Thread Libraries  Threading Issues  Operating System Examples  Windows XP.
Operating System Concepts
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.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
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.
Lecture 5. Example for periority The average waiting time : = 41/5= 8.2.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Multithreaded Programming.
Introduction to threads
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 4 Threads.
Threads & multithreading
Operating System Concepts
Chapter 4 Multithreading programming
CS Introduction to Operating Systems
Presentation transcript:

T HREADS Gursharan Singh Tatla 27-Jan

T HREAD A thread is a single sequential flow of execution of the tasks of a process. A thread is a lightweight process and the smallest unit of CPU utilization. Thus, a thread is like a miniprocess. Each thread has a thread id, program counter, register set and a stack. A thread undergoes different states such as new, ready, running, waiting and terminated similar to that of a process. However, a thread is not a program as it cannot run on its own. It runs within a program. 27-Jan

M ULTI -T HREADING A process can have single thread of control or multiple threads of control. If a process has single thread of control, it can perform only one task at a time. Many modern operating systems have extended the process concept to allow a process to have multiple threads. Thus, allowing the process to perform multiple tasks at the same time. This concept is known as Multi-Threading. 27-Jan

M ULTI -T HREADING For e.g.: The tasks in a web browser are divided into multiple threads. Downloading the images, downloading the text and displaying images and text. While one thread is busy in downloading the images, another thread displays it. The various operating systems the implement multithreading are Windows XP, Vista, 7, Server 2000 onwards, Linux etc. In multithreading, a thread can share its code, data and resources with other threads of same process. 27-Jan

S INGLE T HREAD & M ULTI -T HREAD 27-Jan

T HREADS & P ROCESSES An idea of how threads & processes can be related to each other is depicted in the fig.: 27-Jan

T HREADS & P ROCESSES There are several similarities and differences between a thread and a process: Similarities: Like process, each thread has its own program counter and stack. Threads share CPU just as a process. Threads also run sequentially, like a process. Threads can create child threads. Threads have the same states as process: new, ready, running, waiting and terminated. 27-Jan

T HREADS & P ROCESSES Differences: Each process has its own distinct address space in the main memory. On the other hand, all threads of a same process share same address space. Threads require less system resources than a process. Threads are not independent of each other, unlike processes. Threads take less time for creation and termination than a process. It takes less time to switch between two threads than to switch between two processes. 27-Jan

T YPES OF T HREADS Threads are of three types: Kernel Level Threads User Level Threads Hybrid Threads 27-Jan

K ERNEL L EVEL T HREADS Threads of processes defined by operating system itself are called Kernel Level Threads. In these types of threads, kernel performs thread creation, scheduling and management. Kernel threads are used for internal workings of operating system. Kernel threads are slower to create and manage. The various operating systems that support kernel level threads are: Windows 2000, XP, Solaris Jan

U SER L EVEL T HREADS The threads of user application process are called User Level Threads. They are implemented in the user space of main memory. User level library (functions to manipulate user threads) is used for thread creation, scheduling and management without any support from the kernel. User level threads are fast to create and manage. 27-Jan

H YBRID T HREADS In hybrid approach, both kernel level threads and user level threads are implemented. For e.g.: Solaris Jan

M ULTI -T HREADING M ODELS Depending on the support for user and kernel threads, there are three multithreading models: Many-to-One Model One-to-One Model Many-to-Many Model 27-Jan

M ANY - TO -O NE M ODEL In this model, many user level threads are mapped to one kernel level thread. Threads are managed in user space. 27-Jan

O NE - TO -O NE M ODEL In this model, each user level thread is mapped to one kernel level thread. 27-Jan

M ANY - TO -M ANY M ODEL In this model, many user level threads are mapped to many kernel level threads. 27-Jan

17