Lecture 5. Example for periority The average waiting time : 6+0+16+18+1= 41/5= 8.2.

Slides:



Advertisements
Similar presentations
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows.
Advertisements

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.
國立台灣大學 資訊工程學系 Chapter 4: Threads. 資工系網媒所 NEWS 實驗室 Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the.
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: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Chapter 4: Multithreaded Programming
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 4: Threads CS 170 TY, Sept 2011.
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.
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: Multithreaded Programming. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Objectives To introduce a notion of a thread.
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.
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.
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. 資工系網媒所 NEWS 實驗室 Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: 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.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 4 Operating Systems.
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.
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 – 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.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Lecture 3 Threads Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Saurav Karmakar. Chapter 4: Threads  Overview  Multithreading Models  Thread Libraries  Threading Issues  Operating System Examples  Windows XP.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Chapter 4: Threads 羅習五. Chapter 4: Threads Motivation and Overview Multithreading Models Threading Issues Examples – Pthreads – Windows XP Threads – Linux.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
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.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Multithreaded Programming.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
Introduction to threads
Chapter 4: Multithreaded Programming
OPERATING SYSTEM CONCEPT AND PRACTISE
Chapter 4: Multithreaded Programming
Chapter 4: Threads.
Chapter 4: Threads.
Operating System Concepts
Chapter 4: Threads.
Chapter 4 Multithreading programming
Chapter 4: Threads.
Chapter 4: Threads.
Modified by H. Schulzrinne 02/15/10 Chapter 4: Threads.
CHAPTER 4:THreads Bashair Al-harthi OPERATING SYSTEM
Multithreaded Programming
Chapter 4: Threads & Concurrency
Chapter 4: Threads.
Presentation transcript:

Lecture 5

Example for periority The average waiting time : = 41/5= 8.2

THREAD

Overview Process : single thread or multi thread Thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems Comprises : – Thread ID – Program counter – Register set – Stack Share with other threads with the same process : (Code – Data – Resources )

Thread Example Web browser – Thread to display image – Thread retrieves data from network Word – Thread display graphics – Thread keystrokes

Single and Multithreaded Processes

Benefits Responsiveness – Allow interactive application to continue running if part of, is blocked Resource Sharing – Threads share code and data by default from process but multi-process needs writing code for share memory or message passing Economy – Allocating memory and resources for process creation is costly. – In new process : more overhead, more time consuming and management Scalability – In multi processor  parallelism multithreading can be greatly increased in a multiprocessor architecture,

Multicore Programming – New Trend : multi-core on a single chip, each core is single process for operating system – Multi core : means parallelism – Multi-core : needs designers of operating system write scheduling algorithms, use multi processing

Multicore Programming Multi-core systems putting pressure on programmers, challenges include 5 points: – Dividing activities – Balance – Data splitting – Data dependency – Testing and debugging

Multicore Programming Dividing activities – Find areas can be divided into separate and concurrent tasks Balance – Tasks perform equal work of equal value Data splitting – As application … data accessed by tasks must be divided to run on separate core. Data dependency – The data accessed by the tasks must be examined for dependencies between two or more tasks. Testing and debugging – Testing and debugging such concurrent programs is inherently more difficult than testing and debugging single-threaded applications.

Concurrent Execution on a Single-core System

Parallel Execution on a Multicore System

Multithread modeling User threads : manage with out kernel Kernel thread: manage by OS User threads are supported above the kernel and are managed without kernel support, whereas kernel threads are supported and managed directly by the operating system.

User Threads Thread management done by user-level threads library Three primary thread libraries: – POSIX Pthreads – Win32 threads – Java threads

Kernel Threads Supported by the Kernel Examples – Windows XP/2000 – Solaris – Linux – Tru64 UNIX – Mac OS X

Multithreading Models Many-to-One One-to-One Many-to-Many

Many-to-One Many user-level threads mapped to single kernel thread User thread library in user space Because one thread can access a kernel at a time, multi thread no parallelism in multi processor

Many-to-One Model

One-to-One Each user-level thread maps to kernel thread - allow parallelism if multiprocessor only draw back: create user thread needs to create kernel thread Examples – Windows NT/XP/2000 – Linux – Solaris 9 and later

One-to-one Model

Many-to-Many Model Allows many user level threads to be mapped to many kernel threads Allows the operating system to create a sufficient number of kernel threads No true concurrency because kernel can schedule only one thread at a time The number of kernel threads may be specific to either a particular application or particular machine Windows NT/2000 with the ThreadFiber package

Many-to-Many Model

Two-level Model Similar to M:M, except that it allows a user thread to be bound to kernel thread

Two-level Model

Thread Libraries Thread library provides programmer with API for creating and managing threads Two primary ways of implementing – Library entirely in user space – Kernel-level library supported by the OS

Pthreads May be provided either as user-level or kernel-level A POSIX standard (IEEE c) API for thread creation and synchronization API specifies behavior of the thread library, implementation is up to development of the library Common in UNIX operating systems (Solaris, Linux, Mac OS X)

win32Threads In c program …. Window.h Is a kernel –level library available on windows system