Sarah Diesburg Operating Systems COP 4610

Slides:



Advertisements
Similar presentations
COSC513 Operating System Research Paper Fundamental Properties of Programming for Parallelism Student: Feng Chen (134192)
Advertisements

Programmability Issues
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Threads. What do we have so far The basic unit of CPU utilization is a process. To run a program (a sequence of code), create a process. Processes are.
Concurrency: Threads, Address Spaces, and Processes Sarah Diesburg Operating Systems COP 4610.
Race Conditions. Isolated & Non-Isolated Processes Isolated: Do not share state with other processes –The output of process is unaffected by run of other.
Continuously Recording Program Execution for Deterministic Replay Debugging.
1 Synchronization Coordinating the Activity of Mostly Independent Entities.
CSCE 212 Quiz 4 – 2/16/11 *Assume computes take 1 clock cycle, loads and stores take 10 cycles and branches take 4 cycles and that they are running on.
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
CPS110: Intro to processes, threads and concurrency Author: Landon Cox.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
CPS110: Intro to processes Landon Cox. OS Complexity  Lines of code  XP: 40 million  Linux 2.6: 6 million  (mostly driver code)  Sources of complexity.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
Agenda  Quick Review  Finish Introduction  Java Threads.
Representation of Data Binary Representation of Instructions teachwithict.weebly.com.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Synchronization Questions answered in this lecture: Why is synchronization necessary? What are race conditions, critical sections, and atomic operations?
1 Introduction to Threads Race Conditions. 2 Process Address Space Revisited Code Data OS Stack (a)Process with Single Thread (b) Process with Two Threads.
6/27/20161 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
Introduction To Software Development Environment.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Computer Organization Exam Review CS345 David Monismith.
Basic concepts of C++ Presented by Prof. Satyajit De
Topic 3 (Textbook - Chapter 3) Processes
Introduction to the C Language
Sarah Diesburg Operating Systems COP 4610
Advanced OS Concepts (For OCR)
COMPSCI210 Recitation 12 Oct 2012 Vamsi Thummala
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Object Oriented Programming COP3330 / CGS5409
The Processor and Machine Language
Turing Machines Acceptors; Enumerators
Instruction Level Parallelism and Superscalar Processors
CGS 3763 Operating Systems Concepts Spring 2013
Memory Protection: Kernel and User Address Spaces
Introduction to the C Language
Computer Organization & Compilation Process
Code Generation.
Concurrency: Threads, Address Spaces, and Processes
CGS 3763 Operating Systems Concepts Spring 2013
COP 4600 Operating Systems Spring 2011
CSCE Fall 2013 Prof. Jennifer L. Welch.
COT 5611 Operating Systems Design Principles Spring 2014
COP 4600 Operating Systems Fall 2010
Process & its States Lecture 5.
Computer Architecture and the Fetch-Execute Cycle
COT 5611 Operating Systems Design Principles Spring 2012
Lecture Topics: 11/1 General Operating System Concepts Processes
Computer Organization
CSCE Fall 2012 Prof. Jennifer L. Welch.
Function “Inputs and Outputs”
2P13 Week 3.
Race Conditions David Ferry CSCI 3500 – Operating Systems
COP 4600 Operating Systems Fall 2010
Programming with Shared Memory Specifying parallelism
Andy Wang Operating Systems COP 4610 / CGF 5765
Computer Organization & Compilation Process
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Problems with Locks Andrew Whitaker CSE451.
EECE.4810/EECE.5730 Operating Systems
Andy Wang Operating Systems COP 4610 / CGF 5765
Concurrency: Threads, Address Spaces, and Processes
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

Sarah Diesburg Operating Systems COP 4610 Cooperating Threads Sarah Diesburg Operating Systems COP 4610

Independent Threads No states shared with other threads Deterministic computation Output depends on input Reproducible Output does not depend on the order and timing of other threads Scheduling order does not matter e.g., compilers

Cooperating Threads Shared states Nondeterministic Nonreproducible e.g., elevator controllers Example: 2 threads sharing the same display Thread A Thread B cout << “ABC”; cout << “123”; You may get “A12BC3”

So, Why Allow Cooperating Threads?

So, Why Allow Cooperating Threads? Shared resources e.g., a single processor Speedup Occurs when threads use different resources at different times Modularity An application can be decomposed into threads

Some Concurrent Programs If threads work on separate data, scheduling does not matter Thread A Thread B x = 1; y = 2;

Some Concurrent Programs If threads share data, the final values are not as obvious Thread A Thread B x = 1; y = 2; x = y + 1; y = y * 2; What are the indivisible operations?

Atomic Operations An atomic operation always runs to completion; it’s all or nothing e.g., memory loads and stores on most machines Many operations are not atomic Double precision floating point store on 32-bit machines

Suppose… Each C statement is atomic Let’s revisit the example…

All Possible Execution Orders Thread A Thread B x = 1; y = 2; x = y + 1; y = y * 2; x = 1 y = 2 x = y + 1 y = 2 x = 1 y = y * 2 y = 2 y = y * 2 x = y + 1 y = y * 2 x = 1 x = y + 1 A decision tree

All Possible Execution Orders Thread A Thread B x = 1; y = 2; x = y + 1; y = y * 2; (x = ?, y = ?) (x = ?, y = 2) (x = 1, y = ?) x = 1 y = 2 (x = 1, y = 2) (x = ?, y = ?) (x = ?, y = 4) x = y + 1 y = 2 x = 1 y = y * 2 (x = ?, y = 2) (x = 3, y = 2) (x = 1, y = 4) (x = 1, y = 4) x = 1 y = 2 x = y + 1 y = y * 2 x = y + 1 y = y * 2 y = y * 2 x = y + 1 (x = ?, y = 4) (x = 3, y = 4) (x = 5, y = 4) (x = 5, y = 4)

Another Example Assume each C statement is atomic Both threads are in the same address space Thread A Thread B j = 0; j = 0; while (j < 10) { while (j > -10) { ++j; --j; } } cout << “A wins”; cout << “B wins”;

So… Who wins? Can the computation go on forever? Race conditions occur when threads share data, and their results depend on the timing of their executions…