Threads math 442 es Jim Fix. Reality vs. Abstraction A computer’s OS manages a lot: multiple users many devices; hardware interrupts multiple application.

Slides:



Advertisements
Similar presentations
Threads. Readings r Silberschatz et al : Chapter 4.
Advertisements

Operating Systems Parallel Systems (Now basic OS knowledge)
Day 10 Threads. Threads and Processes  Process is seen as two entities Unit of resource allocation (process or task) Unit of dispatch or scheduling (thread.
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Operating Systems Parallel Systems and Threads (Soon to be basic OS knowledge)
Ceng Operating Systems Chapter 2.5 : Threads Process concept  Process scheduling  Interprocess communication  Deadlocks  Threads.
Threads vs. Processes April 7, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
3.5 Interprocess Communication
Threads CSCI 444/544 Operating Systems Fall 2008.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
Process Concept An operating system executes a variety of programs
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
CS 3013 & CS 502 Summer 2006 Threads1 CS-3013 & CS-502 Summer 2006.
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 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
CS 153 Design of Operating Systems Spring 2015
Operating Systems CMPSC 473 Threads September 16, Lecture 7 Instructor: Bhuvan Urgaonkar.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Threads, Thread management & Resource Management.
1 Threads, SMP, and Microkernels Chapter 4. 2 Focus and Subtopics Focus: More advanced concepts related to process management : Resource ownership vs.
E X C E E D I N G E X P E C T A T I O N S OP SYS Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Functions of an operating.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
CS333 Intro to Operating Systems Jonathan Walpole.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Chapter 4 – Threads (Pgs 153 – 174). Threads  A "Basic Unit of CPU Utilization"  A technique that assists in performing parallel computation by setting.
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.
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.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Department of Computer Science and Software Engineering
1 Chapter 2.5 : Threads Process concept  Process concept  Process scheduling  Process scheduling  Interprocess communication  Interprocess communication.
Threads, Thread management & Resource Management.
Threads. Readings r Silberschatz et al : Chapter 4.
Goals for Today How do we provide multiprogramming? What are Processes? How are they related to Threads and Address Spaces? Note: Some slides and/or pictures.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-2: Threads Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
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.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Introduction to Operating Systems Concepts
Introduction to threads
CSCI 511 Operating Systems Chapter 3,4 (Part A) Processes and Threads
CS 6560: Operating Systems Design
Processes and Threads Processes and their scheduling
OPERATING SYSTEMS CS3502 Fall 2017
CS399 New Beginnings Jonathan Walpole.
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 4: Multithreaded Programming
Chapter 4 Threads.
Threads & multithreading
Chapter 4: Threads.
Operating System Concepts
CSCI 511 Operating Systems Chapter 3,4 (Part A) Processes and Threads
Chapter 15, Exploring the Digital Domain
CSE 153 Design of Operating Systems Winter 2018
CSE 451: Operating Systems Autumn 2003 Lecture 5 Threads
Threads and Concurrency
CSE 451: Operating Systems Winter 2003 Lecture 5 Threads
Operating Systems (CS 340 D)
Threads vs. Processes Hank Levy 1.
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 2019
CSE 451: Operating Systems Winter 2001 Lecture 5 Threads
Presentation transcript:

Threads math 442 es Jim Fix

Reality vs. Abstraction A computer’s OS manages a lot: multiple users many devices; hardware interrupts multiple application programs multiple processors/cores... but a modern OS presents a different reality to application programmers

API Layers Most APIs’ (Application’s Programming Interfaces’) goal is to abstract away the underlying HW/SW system details. ``file”, ``socket’’, ``address”, ``lock”,... libraries form this abstraction layer CPU I/O memory OS application pgm libraries la la land the real deal

Example: Unix ``process” abstraction of what is associated with execution of a program two major components: a ``thread” of control (execution state) address space (execution context) gives the illusion that a program has exclusive access to a single machine

A Unix Process Recall our depiction of a process:.data stack heap.text.bss address space hi execution state lo RegF SP PC CC file descriptors, scheduler info,... OS info see

Why not......have multiple threads of control?.data heap.bss hi TCB 1 lo RegF SP PC CC file descriptors, scheduler info,... OS info TCB 2 RegF SP PC CC.text TCB = thread control block

Thread / “lightweight process” Let’s decouple ``address space” & ``thread”? Allow multiple threads to share an address space and OS context Give the illusion of having multiple processors (Why is this useful?)

Example use of threads: In a web browser: one thread renders a page while another fetches data and another displays a media stream &c

Example use of threads: In a web server: ``master” thread that fields requests ``worker” threads that handle requests script execution (remote) database access &c

Example use of threads: Embedded/control systems are naturally multithreaded airplane navigation medical equipment factory control > many system components; somewhat independent.

Benefits: code structure Code might naturally......manage multiple tasks: e.g. web browser; emb’d sys.; evil dwg robot...handle concurrent/asynchronous events e.g., server; r-t sys.; videogame; evil dwg robot...have lots of (data) parallelism e.g., raytracer; videogame; 100 evil dwg robots, centrally controlled > many system components; somewhat independent.

Benefits: performance I/O op may be blocking waiting for data; can do other useful work faster response time; requests don’t get queued up may actually execute on different processor cores (true concurrency) different physical resources can be used simultaneously (true parallelism)

Perf. Gains multi-process vs. multi-thread overhead: process creation and all that it entails (process ``fork”: new VM mgmt, address space copy) overhead of inter-process communication (IPC) overhead of system calls ``heavyweight” threads are sometimes called ``lightweight processes”

Perf. Gains (see H. Levy’s data) (see LLNL’s data)

Issues (C) thread library API? thread library implementation? who’s responsible for managing threads? (Kernel vs. User-level) (>C) language abstraction? Also... It’s just a fact: writing multi-threaded programs is hard.

Reading ``THE microprogramming system”, ``THE microprogramming system”, (Dijkstra, 1968) ``Prgmg w/ Threads” (Birrel, 1989) ``POSIX threads” (LLNL,2008)

POSIX threads Standardized pthread library routines (actually, several) for: creation/joining setting attributes mutual exclusion software condition (queues) see