Why Concurrency? Allows multiple applications to run at the same time  Analogy: juggling.

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

Process management Information maintained by OS for process management  process context  process control block OS virtualization of CPU for each process.
CHAPTER 5 THREADS & MULTITHREADING 1. Single and Multithreaded Processes 2.
Concurrency: Threads, Address Spaces, and Processes Sarah Diesburg Operating Systems COP 4610.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
Operating Systems Parallel Systems (Now basic OS knowledge)
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
Operating Systems Parallel Systems and Threads (Soon to be basic OS knowledge)
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
OS Spring’03 Introduction Operating Systems Spring 2003.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
1 Chapter 4 Threads Threads: Resource ownership and execution.
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Process Concept An operating system executes a variety of programs
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Operating Systems CSE 411 CPU Management Sept Lecture 11 Instructor: Bhuvan Urgaonkar.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Threads Many software packages are multi-threaded Web browser: one thread display images, another thread retrieves data from the network Word processor:
Concurrency: Threads, Address Spaces, and Processes Andy Wang Operating Systems COP 4610 / CGS 5765.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 13 Threads Read Ch 5.1.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Processes Questions answered in this lecture: What is a process? How does the dispatcher context-switch between processes? How does the OS create a new.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
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.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Department of Computer Science and Software Engineering
Processes & Threads Introduction to Operating Systems: Module 5.
1 OS Review Processes and Threads Chi Zhang
Multithreading The objectives of this chapter are: To understand the purpose of multithreading To describe Java's multithreading mechanism.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Process concept.
Process Management Process Concept Why only the global variables?
CSCS 511 Operating Systems Ch3, 4 (Part B) Further Understanding Threads Dr. Frank Li Skipped sections 3.5 & 3.6 
Lecture Topics: 11/1 Processes Process Management
Operating System Concepts
Concurrency: Threads, Address Spaces, and Processes
Process management Information maintained by OS for process management
CSCI 511 Operating Systems Ch3, 4 (Part B) Further Understanding Threads Dr. Frank Li Skipped sections 3.5 & 3.6 
Threads, SMP, and Microkernels
Concurrency: Threads, Address Spaces, and Processes
Process & its States Lecture 5.
PROCESS MANAGEMENT Information maintained by OS for process management
Lecture Topics: 11/1 General Operating System Concepts Processes
Threads and Concurrency
Operating Systems Processes (Ch 4.1).
Threads Chapter 5 2/17/2019 B.Ramamurthy.
Threads Chapter 5 2/23/2019 B.Ramamurthy.
Processes David Ferry CSCI 3500 – Operating Systems
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Operating System Overview
Concurrency: Threads, Address Spaces, and Processes
Operating Systems Processes (Ch 2.1).
Presentation transcript:

Why Concurrency? Allows multiple applications to run at the same time  Analogy: juggling

Benefits of Concurrency Ability to run multiple applications at the same time Better resource utilization  Resources unused by one application can be used by the others Better average response time  No need to wait for other applications to complete

Benefits of Concurrency Better performance  One application uses only the processor  One application uses only the disk drive  Completion time is shorter when running both concurrently than consecutively

Drawbacks of Concurrency Applications need to be protected from one another Additional coordination mechanisms among applications Overhead to switch among applications Potential performance degradation when running too many applications

Thread A sequential execution stream  The smallest CPU scheduling unit  Can be programmed as if it owns the entire CPU Implication: an infinite loop within a thread won’t halt the system  Illusion of multiple CPUs on a single machine

Thread States Program counter Register values Execution stacks

Thread Benefits Simplified programming model per thread Example: Microsoft Word  One thread for grammar check; one thread for spelling check; one thread for formatting; and so on…  Can be programmed independently  Simplifies the development of large applications

Address Space Contains all states necessary to run a program  Code, data, stack  Program counter  Register values  Resources required by the program  Status of the running program

Process An address space + at least one thread of execution  Address space offers protection among processes  Threads offer concurrency A fundamental unit of computation

Process =? Program Program: a collection of statements in C or any programming languages Process: a running instance of the program, with additional states and system resources

Process >? Program Two processes can run the same program  The code segment of two processes are the same program

Program >? Process A program can create multiple processes  Example: gcc, netscape

Analogy Program: a recipe Process: everything needed to cook  e.g., kitchen Two chefs can cook the same recipe in different kitchens One complex recipe can involve several chefs

Some Definitions Uniprogramming: running one process at a time Multiprogramming: running multiple processes on a machine

Some Definitions Multithreading: having multiple threads per address space Multiprocessing: running programs on a machine with multiple processors Multitasking: a single user can run multiple processes

Classifications of OSes Single address space Multiple address spaces Single threadMS DOS, Macintosh Traditional UNIX Multiple threads Embedded systems Windows NT, Solaris, OS/2

Threads & Dispatching Loop A thread owns a thread control block  Execution states of the thread  The status of the thread Running or sleeping  Scheduling information of the thread e.g., priority

Dispatching Loop Threads are run from a dispatching loop  LOOP Run thread Save states Choose a new thread to run Load states from a different thread Jump to the first instruction Context switch Scheduling

Simple? Not Quite… How does the dispatcher regain control after a thread starts running? What states should a thread save? How does the dispatcher choose the next thread?

How Does the Dispatcher Regain Control? Two ways: 1. Internal events (“Sleeping Beauty”)  A thread is waiting for I/O  A thread is waiting for some other thread  Yield—a thread gives up CPU voluntarily 2. External events  Interrupts—a complete disk request  Timer—it’s like an alarm clock

What States Should a Thread Save? Anything that the next thread may trash before a context switch  Program counter  Registers  Changes in execution stack

How Does the Dispatcher Choose the Next Thread? The dispatcher keeps a list of threads that are ready to run If no threads are ready  Dispatcher just loops If one thread is ready  Easy

How Does the Dispatcher Choose the Next Thread? If more than one thread are ready  We choose the next thread based on the scheduling policies  Examples FIFO (first in, first out) LIFO (last in, first out) Priority-based policies

How Does the Dispatcher Choose the Next Thread? Additional control by the dispatcher on how to share the CPU  Examples: ABC Time Run to completion ABCABCACAC Time Timeshare the CPU

Per-Thread States Each thread can be in one of the three states 1. Running: has the CPU 2. Blocked: waiting for I/O or another thread 3. Ready to run: on the ready list, waiting for the CPU

Per-Thread State Diagram Ready Yield, timer I/O complete Running Scheduled Blocked I/O request