Thread Synchronization

Slides:



Advertisements
Similar presentations
CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
Advertisements

Test practice Multiplication. Multiplication 9x2.
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Threading Part 2 CS221 – 4/22/09. Where We Left Off Simple Threads Program: – Start a worker thread from the Main thread – Worker thread prints messages.
V Storage Manager Shahram Ghandeharizadeh Computer Science Department University of Southern California.
1 Lecture 21: Synchronization Topics: lock implementations (Sections )
1 MATERI PENDUKUNG SINKRONISASI Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
CS510 Concurrent Systems Class 5 Threads Cannot Be Implemented As a Library.
1 Lecture 20: Protocols and Synchronization Topics: distributed shared-memory multiprocessors, synchronization (Sections )
Lesson 4-6: Consistent & Dependent Systems Objective: Students will: Determine whether a system of equations is consistent, inconsistent, or dependent.
ECE200 – Computer Organization Chapter 9 – Multiprocessors.
Internet Software Development Controlling Threads Paul J Krause.
Solving Systems of Equations.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Concurrency & Dynamic Programming.
SATMathVideos.Net A set S consists of all multiples of 4. Which of the following sets are contained within set S? A) S2 only B) S4 only C) S2 and S4 D)
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Process Synchronization. Objectives To introduce the critical-section problem, whose solutions can be used to ensure the consistency of shared data To.
Software Design 13.1 From controller to threads l Threads are lightweight processes (what’s a process?)  Threads are part of a single program, share state.
December 1, 2006©2006 Craig Zilles1 Threads & Atomic Operations in Hardware  Previously, we introduced multi-core parallelism & cache coherence —Today.
Multiprocessors – Locks
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Background on the need for Synchronization
Process Synchronization
Lecture 21 Synchronization
PHyTM: Persistent Hybrid Transactional Memory
Lecture 19: Coherence and Synchronization
Lecture 5: Synchronization
Atomic Operations in Hardware
Multithreading Tutorial
Atomic Operations in Hardware
Lecture 18: Coherence and Synchronization
Lecture 25 More Synchronized Data and Producer/Consumer Relationship
Reactive Synchronization Algorithms for Multiprocessors
Lecture 8 Thread Safety.
Lecture 11: Mutual Exclusion
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Semaphore and Multithreading
Designing Parallel Algorithms (Synchronization)
Symmetric Multiprocessors: Synchronization and Sequential Consistency
Review and Q/A.
Multithreading Tutorial
Process Synchronization
Lecture 21: Synchronization and Consistency
Lecture: Coherence and Synchronization
Background and Motivation
Scalable lock-free Stack Algorithm
Grades.
Dr. Mustafa Cem Kasapbaşı
Concurrency: Mutual Exclusion and Process Synchronization
Chapter 6: Process Synchronization
Multithreading Tutorial
Lecture 25: Multiprocessors
Multithreading Tutorial
Lecture 4: Synchronization
EE 4xx: Computer Architecture and Performance Programming
Concurrency and Immutability
Lecture 11: Mutual Exclusion
- When you approach operating system concepts there might be several confusing terms that may look similar but in fact refer to different concepts:  multiprogramming, multiprocessing, multitasking,
CS333 Intro to Operating Systems
Lecture 24: Multiprocessors
Chapter 6: Synchronization Tools
Lecture 21: Synchronization & Consistency
Lecture: Coherence and Synchronization
Lecture 19: Coherence and Synchronization
Modified at -
EE 155 / COMP 122: Parallel Computing
Lecture 18: Coherence and Synchronization
Ch 3.
Presentation transcript:

Thread Synchronization

Consistency Problems Multiple threads share the same memory: Must make sure that each thread sees a consistent view of its data. No consistency problem exists: Each thread uses variables that other threads don't read or modify If a variable is read-only, because many threads may read its value at the same time. Consistency problem: One thread can modify a variable that other threads can read or modify Need to synchronize the threads to ensure that they don't use an invalid value when accessing the variable's memory contents. If one thread modifies a variable, other threads can potentially see inconsistencies when reading the value of the variable

Consistency Problems Threads have to use a lock that will allow only one thread to access the variable at a time.

Consistency Problems

Consistency Problems Need to synchronize >=2 threads that might try to modify the same variable at the same time. For example, in the case in which we need to increment a variable: Read the memory location into a register. Increment the value in the register. Write the new value back to the memory location.

Consistency Problems