On the C11 Memory Model and a Program Logic for C11 Concurrency

Size: px
Start display at page:

Download "On the C11 Memory Model and a Program Logic for C11 Concurrency"

Transcription

1 On the C11 Memory Model and a Program Logic for C11 Concurrency Manuel Penschuck Aktuelle Themen der Softwaretechnologie Software Engineering & Programmiersprachen FB 12 Goethe Universität - Frankfurt am Main 04. Feb Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

2 Topics 1 Motivation 2 C11 Memory Model Atomic Accesses 3 Logic The Hoare Triple Separation Logic Relaxed Separation Logic 4 Conclusion Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

3 Common Weakness Enumeration 1 TOP 25 Most Dangerous Software Errors 41 CWE-456: Missing Initialisation 40 CWE-825: Expired Pointer Dereference 36 CWE-476: NULL Pointer Dereference 33 CWE-362: Concurrent Execution using Shared Resource with Improper Synchronisation Race Condition int init = 1; int uninit; int result = init + uninit; 1 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

4 Common Weakness Enumeration 1 TOP 25 Most Dangerous Software Errors 41 CWE-456: Missing Initialisation 40 CWE-825: Expired Pointer Dereference 36 CWE-476: NULL Pointer Dereference 33 CWE-362: Concurrent Execution using Shared Resource with Improper Synchronisation Race Condition freep; *p = 47; 1 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

5 Common Weakness Enumeration 1 TOP 25 Most Dangerous Software Errors 41 CWE-456: Missing Initialisation 40 CWE-825: Expired Pointer Dereference 36 CWE-476: NULL Pointer Dereference 33 CWE-362: Concurrent Execution using Shared Resource with Improper Synchronisation Race Condition p = mallocsizeofint; // out of memory! *p = 42; 1 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

6 Common Weakness Enumeration 1 TOP 25 Most Dangerous Software Errors 41 CWE-456: Missing Initialisation 40 CWE-825: Expired Pointer Dereference 36 CWE-476: NULL Pointer Dereference 33 CWE-362: Concurrent Execution using Shared Resource with Improper Synchronisation Race Condition tmp = shared; tmp = tmp&1? 3*tmp +1 : tmp>>1; shared = tmp; 1 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

7 Hidden Races int data = 0; void worker forint i=0; i < N; i++ data++; } } int main.. pardo [worker worker] and join; printf"data=%d", data; } Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

8 Hidden Races void worker // gcc -O0 forint i=0; i < N; i++ register int tmp = data; // RAM: expensive tmp++; data = tmp; // RAM: expensive } } void worker // gcc -O1 register int tmp = data; forint i=0; i < N; i++ tmp++; data = tmp; } void worker // gcc -O3 register int tmp = data; tmp += N; data = tmp; } Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

9 Situation until now C99/C0X standard: purely sequential Thread and synchronisation support via libraries PThread, TBB, MS Windows Runtime Lib, C++/BOOST,... Limited compiler support Optimisation unsound in concurrent programs? Synchronisation inefficient sync in GCC Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

10 Situation until now C99/C0X standard: purely sequential Thread and synchronisation support via libraries PThread, TBB, MS Windows Runtime Lib, C++/BOOST,... Limited compiler support Optimisation unsound in concurrent programs? Synchronisation inefficient sync in GCC Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

11 Situation until now C99/C0X standard: purely sequential Thread and synchronisation support via libraries PThread, TBB, MS Windows Runtime Lib, C++/BOOST,... Limited compiler support Optimisation unsound in concurrent programs? Synchronisation inefficient sync in GCC Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

12 Some Extensions of C11 Optional concurrency mode Threads via threads.h similar to POSIX threads thread management, mutex, barrier Atomic Memory Access via stdatomic.h Memory Model! Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

13 Some Extensions of C11 Optional concurrency mode Threads via threads.h similar to POSIX threads thread management, mutex, barrier Atomic Memory Access via stdatomic.h Memory Model! Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

14 Some Extensions of C11 Optional concurrency mode Threads via threads.h similar to POSIX threads thread management, mutex, barrier Atomic Memory Access via stdatomic.h Memory Model! Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

15 Some Extensions of C11 Optional concurrency mode Threads via threads.h similar to POSIX threads thread management, mutex, barrier Atomic Memory Access via stdatomic.h Memory Model! Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

16 C11 Memory Model Extends existing evaluation rules Allow compiler and processor as many optimisations as possible Support for Sequential consistency Acquire-Release Consume-Release Relaxed just atomic Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

17 C11 Memory Model Extends existing evaluation rules Allow compiler and processor as many optimisations as possible Support for Sequential consistency Acquire-Release Consume-Release Relaxed just atomic Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

18 C11 Memory Model Extends existing evaluation rules Allow compiler and processor as many optimisations as possible Support for Sequential consistency Acquire-Release Consume-Release Relaxed just atomic Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

19 Acquire-Release All effects of instructions preceding a release R have be observable before R All reads succeeding an acquire A have to happen after A Very efficient on x86 plain reads/writes load store Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

20 Acquire-Release All effects of instructions preceding a release R have be observable before R All reads succeeding an acquire A have to happen after A Very efficient on x86 plain reads/writes [v]na 47 [f ] rel 1 v alloc; r alloc; f alloc; [f ] rlx 0; repeat [f ]acq end r [v] na Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

21 Acquire-Release All effects of instructions preceding a release R have be observable before R All reads succeeding an acquire A have to happen after A Very efficient on x86 plain reads/writes [v]na 47 [f ] rel 1 v alloc; r alloc; f alloc; [f ] rlx 0; repeat [f ]acq end r [v] na Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

22 stdatomic.h atomic_load, -store atomic_fetch_add, -sub, -or, -xor, -and atomic_exchange atomic_compare_exchange_weak, -strong atomic_flag_clear, -test_and_set... Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

23 stdatomic.h atomic_load, -store atomic_fetch_add, -sub, -or, -xor, -and atomic_exchange atomic_compare_exchange_weak, -strong atomic_flag_clear, -test_and_set... forint i=0; i<n; i++ // data++; atomic_fetch_add&data, 1; } Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

24 stdatomic.h atomic_load, -store atomic_fetch_add, -sub, -or, -xor, -and atomic_exchange atomic_compare_exchange_weak, -strong atomic_flag_clear, -test_and_set... atomic_exchange*p, val{ old = *p; *p = val; return old; } Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

25 stdatomic.h atomic_load, -store atomic_fetch_add, -sub, -or, -xor, -and atomic_exchange atomic_compare_exchange_weak, -strong atomic_flag_clear, -test_and_set... atomic_compare_exchange*p,ref,val{ old = *p; if old == ref *p = val; return true; } return false; } spinlock*p, threadid whileat_com_xchg_weak p, 0, threadid; } Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

26 stdatomic.h atomic_load, -store atomic_fetch_add, -sub, -or, -xor, -and atomic_exchange atomic_compare_exchange_weak, -strong atomic_flag_clear, -test_and_set... Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

27 Program Logics Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

28 The Hoare Triple P Q R If the assertion P is true before [the] initiation of a program Q, then the assertion R will be true on its completion [if the program terminates]. x 1 x x + 1 x 2 x 1 while true; x 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

29 The Hoare Triple P Q R If the assertion P is true before [the] initiation of a program Q, then the assertion R will be true on its completion [if the program terminates]. x 1 x x + 1 x 2 x 1 while true; x 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

30 The Hoare Triple P Q R If the assertion P is true before [the] initiation of a program Q, then the assertion R will be true on its completion [if the program terminates]. x 1 x x + 1 x 2 x 1 while true; x 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

31 The Hoare Triple P Q R If the assertion P is true before [the] initiation of a program Q, then the assertion R will be true on its completion [if the program terminates]. x 1 x x + 1 x 2 x 1 while true; x 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

32 Hoare Logic: Rule of Composition P Q1 R R Q2 T P Q1 ; Q 2 T x 1 x x + 1 x 2 x 2 y x x 2 y 2 x 1 x x + 1; y x x 2 y 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

33 Hoare Logic: Rule of Composition P Q1 R R Q2 T P Q1 ; Q 2 T x 1 x x + 1 x 2 x 2 y x x 2 y 2 x 1 x x + 1; y x x 2 y 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

34 Separation Logic Targets shared data structures pointers, references Efficient fully-automated verifier Distinguishes between Registers represented by the Stack s : Vars Values with doms < Addressable Memory represented by the Heap h : Addresses Values with domh < Separates independent code sections using the separation conjunction Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

35 Separation Logic Targets shared data structures pointers, references Efficient fully-automated verifier Distinguishes between Registers represented by the Stack s : Vars Values with doms < Addressable Memory represented by the Heap h : Addresses Values with domh < Separates independent code sections using the separation conjunction Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

36 Separation Logic Targets shared data structures pointers, references Efficient fully-automated verifier Distinguishes between Registers represented by the Stack s : Vars Values with doms < Addressable Memory represented by the Heap h : Addresses Values with domh < Separates independent code sections using the separation conjunction Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

37 Separation Logic Targets shared data structures pointers, references Efficient fully-automated verifier Distinguishes between Registers represented by the Stack s : Vars Values with doms < Addressable Memory represented by the Heap h : Addresses Values with domh < Separates independent code sections using the separation conjunction Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

38 Separation Logic: Framing Rule p Q1 q p r Q1 q r x y x 2 y 2 [x] 3 x 3 y 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

39 Separation Logic: Framing Rule p Q1 q p r Q1 q r x y x 2 y 2 [x] 3 x 3 y 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

40 Separation Logic: Framing Rule p Q1 q p r Q1 q r x y x 2 y 2 [x] 3 x 3 y 2 x = y x 2 y 2 [x] 3 x 3 y 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

41 Separation Logic: Framing Rule p Q1 q p r Q1 q r x y x 2 y 2 [x] 3 x 3 y 2 x = y x 2 y 2 [x] 3 x 3 y 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

42 Relaxed Separation Logic A complete C-language subset Rules to infer a Hoare-Triple annotation Central Theorem Coq-proven: If annotation is successful program is memory sound Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

43 Relaxed Separation Logic P, Q := complete first order logic {}}{ false P k Q x. P known from SL {}}{ emp e k e P Q Rele, Q Acqe, Q RMWAcqe, Q Inite Uninite Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

44 Relaxed Separation Logic P, Q := complete first order logic {}}{ false P k Q x. P known from SL {}}{ emp e k e P Q Rele, Q Acqe, Q RMWAcqe, Q Inite Uninite Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

45 Relaxed Separation Logic P, Q := complete first order logic {}}{ false P k Q x. P known from SL {}}{ emp e k e P Q Rele, Q Acqe, Q RMWAcqe, Q Inite Uninite Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

46 Relaxed Separation Logic [v]na 47 [f ] rel 1 emp v alloc; r alloc; f alloc; [f ] rlx 0; repeat [f ]acq end [r] na [v] na Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

47 Relaxed Separation Logic [v]na 47 [f ] rel 1 emp v alloc; r alloc; Uninitv Uninitr f alloc; [f ] rlx 0; repeat [f ]acq end [r] na [v] na Non-Atomic Allocation emp alloc x. Uninitx Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

48 Relaxed Separation Logic v alloc; r alloc; Uninitv Uninitr f alloc; Uninitv Uninitr Relf, Q Acqf, Q [v]na 47 [f ] rel 1 [f ] rlx 0; repeat [f ]acq end [r] na [v] na Atomic Allocation emp alloc x. Relx, Q Acqx, Q Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

49 Relaxed Separation Logic v alloc; r alloc; f alloc; Uninitv Uninitr Relf, Q Acqf, Q [f ] rlx 0; Uninitv Uninitr Relf, Q Acqf, Q Initf [v]na 47 repeat [f ]acq end [f ] rel 1 [r] na [v] na Relaxed Write simplified Rel.. [l] v Initl Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

50 Relaxed Separation Logic v alloc; r alloc; f alloc; [f ] rlx 0; Uninitv Uninitr Relf, Q Acqf, Q Initf Uninitv Relf, Q Uninitr Acqf, Q Initf [v] na 47 repeat [f ] acq end [f ] rel 1 [r] na [v] na Parallel Composition P1 Q1 R1 P2 Q2 R2 P1 P 2 Q1 Q 2 R1 R 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

51 Relaxed Separation Logic Uninitv Relf, Q [v] na 47 v 47 Relf, Q [f ] rel 1 v alloc; r alloc; f alloc; [f ] rlx 0; Uninitr Acqf, Q Initf repeat [f ] acq end [r] na [v] na Non-Atomic Write 1 l _ Uninitl [l]na v 1 l v Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

52 Relaxed Separation Logic [v] na 47 v} {{ 47} Relf, Q Q [f ] rel 1 Relf, Q v alloc; r alloc; f alloc; [f ] rlx 0; Uninitr Acqf, Q Initf repeat [f ] acq end [r] na [v] na Atomic Write Qv Rell, Q [l]rel v Initl Rell, Q Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

53 Relaxed Separation Logic [v] na 47 [f ] rel 1 Relf, Q v alloc; r alloc; f alloc; [f ] rlx 0; Uninitr Acqf, Q Initf repeat [f ] acq end v 1 47 Uninitr true }{{} Q [r] na [v] na Atomic Read simplified Initl Acql, Q [l]acq v.qv Acq... Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

54 Relaxed Separation Logic [v] na 47 [f ] rel 1 v alloc; r alloc; f alloc; [f ] rlx 0; repeat [f ] acq end v } {{ 1 47} Uninitr true Q [r] na [v] na true r 47 v 47 Non-Atomic Read k k l v [l]na x.x = v l v Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

55 Relaxed Separation Logic [v] na 47 [f ] rel 1 Relf, Q v alloc; r alloc; f alloc; [f ] rlx 0; repeat [f ] acq end [r] na [v] na true r 47 v 47 true r 47 Parallel Composition P1 Q1 R1 P2 Q2 R2 P1 P 2 Q1 Q 2 R1 R 2 Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

56 Conclusion & Outlook C11 is now officially fit for concurrent programs RSL shows how to perform formal arguments on subset of C11-MM Fully automated verifier? Thank you for your attention! Questions? Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

57 Conclusion & Outlook C11 is now officially fit for concurrent programs RSL shows how to perform formal arguments on subset of C11-MM Fully automated verifier? Thank you for your attention! Questions? Uni Frankfurt FB 12 C11-MM / Relaxed Separation Logic 04. Feb / 19

Program logics for relaxed consistency

Program logics for relaxed consistency Program logics for relaxed consistency UPMARC Summer School 2014 Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) 1st Lecture, 28 July 2014 Outline Part I. Weak memory models 1. Intro

More information

Reasoning about the C/C++ weak memory model

Reasoning about the C/C++ weak memory model Reasoning about the C/C++ weak memory model Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) 13 October 2014 Talk outline I. Introduction Weak memory models The C11 concurrency model

More information

A Program Logic for C11 Memory Fences

A Program Logic for C11 Memory Fences A Program Logic for C11 Memory Fences Marko Doko and Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) Abstract. We describe a simple, but powerful, program logic for reasoning about

More information

Relaxed Separation Logic: A Program Logic for C11 Concurrency

Relaxed Separation Logic: A Program Logic for C11 Concurrency Relaxed Separation Logic: A rogram Logic for C11 Concurrency Viktor Vafeiadis Max lanck Institute for Software Systems (MI-SWS) viktor@mpi-sws.org Chinmay Narayan Indian Institute of Technology, Delhi

More information

CS 261 Fall Mike Lam, Professor. Threads

CS 261 Fall Mike Lam, Professor. Threads CS 261 Fall 2017 Mike Lam, Professor Threads Parallel computing Goal: concurrent or parallel computing Take advantage of multiple hardware units to solve multiple problems simultaneously Motivations: Maintain

More information

An introduction to weak memory consistency and the out-of-thin-air problem

An introduction to weak memory consistency and the out-of-thin-air problem An introduction to weak memory consistency and the out-of-thin-air problem Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) CONCUR, 7 September 2017 Sequential consistency 2 Sequential

More information

CS510 Advanced Topics in Concurrency. Jonathan Walpole

CS510 Advanced Topics in Concurrency. Jonathan Walpole CS510 Advanced Topics in Concurrency Jonathan Walpole Threads Cannot Be Implemented as a Library Reasoning About Programs What are the valid outcomes for this program? Is it valid for both r1 and r2 to

More information

CS510 Operating System Foundations. Jonathan Walpole

CS510 Operating System Foundations. Jonathan Walpole CS510 Operating System Foundations Jonathan Walpole Threads & Concurrency 2 Why Use Threads? Utilize multiple CPU s concurrently Low cost communication via shared memory Overlap computation and blocking

More information

Hoare Logic and Model Checking

Hoare Logic and Model Checking Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Pointers Pointers and

More information

Separation Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré. Australian National University Semester 2, 2016

Separation Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré. Australian National University Semester 2, 2016 Separation Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 COMP 2600 Separation Logic 1 Motivation: Reasoning About Pointers Recall this

More information

Hoare Logic and Model Checking

Hoare Logic and Model Checking Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Introduction In the

More information

The C/C++ Memory Model: Overview and Formalization

The C/C++ Memory Model: Overview and Formalization The C/C++ Memory Model: Overview and Formalization Mark Batty Jasmin Blanchette Scott Owens Susmit Sarkar Peter Sewell Tjark Weber Verification of Concurrent C Programs C11 / C++11 In 2011, new versions

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 The Process Concept 2 The Process Concept Process a program in execution

More information

Hoare Logic and Model Checking. A proof system for Separation logic. Introduction. Separation Logic

Hoare Logic and Model Checking. A proof system for Separation logic. Introduction. Separation Logic Introduction Hoare Logic and Model Checking In the previous lecture we saw the informal concepts that Separation Logic is based on. Kasper Svendsen University of Cambridge CST Part II 2016/17 This lecture

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 Process creation in UNIX All processes have a unique process id getpid(),

More information

CS533 Concepts of Operating Systems. Jonathan Walpole

CS533 Concepts of Operating Systems. Jonathan Walpole CS533 Concepts of Operating Systems Jonathan Walpole Introduction to Threads and Concurrency Why is Concurrency Important? Why study threads and concurrent programming in an OS class? What is a thread?

More information

Static Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security

Static Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security Static Analysis: Overview, Syntactic Analysis and Abstract Interpretation TDDC90: Software Security Ahmed Rezine IDA, Linköpings Universitet Hösttermin 2014 Outline Overview Syntactic Analysis Abstract

More information

Advances in Programming Languages

Advances in Programming Languages O T Y H Advances in Programming Languages APL8: ESC/Java2 David Aspinall (including slides by Ian Stark and material adapted from ESC/Java2 tutorial by David Cok, Joe Kiniry and Erik Poll) School of Informatics

More information

Hoare logic. A proof system for separation logic. Introduction. Separation logic

Hoare logic. A proof system for separation logic. Introduction. Separation logic Introduction Hoare logic Lecture 6: Examples in separation logic In the previous lecture, we saw how reasoning about pointers in Hoare logic was problematic, which motivated introducing separation logic.

More information

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to

More information

Foundations of the C++ Concurrency Memory Model

Foundations of the C++ Concurrency Memory Model Foundations of the C++ Concurrency Memory Model John Mellor-Crummey and Karthik Murthy Department of Computer Science Rice University johnmc@rice.edu COMP 522 27 September 2016 Before C++ Memory Model

More information

Shared-Memory Programming

Shared-Memory Programming Shared-Memory Programming 1. Threads 2. Mutual Exclusion 3. Thread Scheduling 4. Thread Interfaces 4.1. POSIX Threads 4.2. C++ Threads 4.3. OpenMP 4.4. Threading Building Blocks 5. Side Effects of Hardware

More information

Threads Cannot Be Implemented As a Library

Threads Cannot Be Implemented As a Library Threads Cannot Be Implemented As a Library Authored by Hans J. Boehm Presented by Sarah Sharp February 18, 2008 Outline POSIX Thread Library Operation Vocab Problems with pthreads POSIX Thread Library

More information

Recency Types for Dynamically-Typed, Object-Based Languages

Recency Types for Dynamically-Typed, Object-Based Languages Recency Types for Dynamically-Typed, Object-Based Languages Phillip Heidegger, Peter Thiemann Albert-Ludwigs-Universität Freiburg 15.10.2008 Task: Maintenance Finding bugs in JavaScript programs Understanding

More information

COMP 3430 Robert Guderian

COMP 3430 Robert Guderian Operating Systems COMP 3430 Robert Guderian file:///users/robg/dropbox/teaching/3430-2018/slides/04_threads/index.html?print-pdf#/ 1/58 1 Threads Last week: Processes This week: Lesser processes! file:///users/robg/dropbox/teaching/3430-2018/slides/04_threads/index.html?print-pdf#/

More information

Synchronising Threads

Synchronising Threads Synchronising Threads David Chisnall March 1, 2011 First Rule for Maintainable Concurrent Code No data may be both mutable and aliased Harder Problems Data is shared and mutable Access to it must be protected

More information

CS 241 Honors Concurrent Data Structures

CS 241 Honors Concurrent Data Structures CS 241 Honors Concurrent Data Structures Bhuvan Venkatesh University of Illinois Urbana Champaign March 27, 2018 CS 241 Course Staff (UIUC) Lock Free Data Structures March 27, 2018 1 / 43 What to go over

More information

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio Fall 2017 1 Outline Inter-Process Communication (20) Threads

More information

Review: Easy Piece 1

Review: Easy Piece 1 CS 537 Lecture 10 Threads Michael Swift 10/9/17 2004-2007 Ed Lazowska, Hank Levy, Andrea and Remzi Arpaci-Dussea, Michael Swift 1 Review: Easy Piece 1 Virtualization CPU Memory Context Switch Schedulers

More information

Hoare logic. WHILE p, a language with pointers. Introduction. Syntax of WHILE p. Lecture 5: Introduction to separation logic

Hoare logic. WHILE p, a language with pointers. Introduction. Syntax of WHILE p. Lecture 5: Introduction to separation logic Introduction Hoare logic Lecture 5: Introduction to separation logic In the previous lectures, we have considered a language, WHILE, where mutability only concerned program variables. Jean Pichon-Pharabod

More information

Hoare logic. Lecture 5: Introduction to separation logic. Jean Pichon-Pharabod University of Cambridge. CST Part II 2017/18

Hoare logic. Lecture 5: Introduction to separation logic. Jean Pichon-Pharabod University of Cambridge. CST Part II 2017/18 Hoare logic Lecture 5: Introduction to separation logic Jean Pichon-Pharabod University of Cambridge CST Part II 2017/18 Introduction In the previous lectures, we have considered a language, WHILE, where

More information

Instructions: Submit your answers to these questions to the Curator as OQ02 by the posted due date and time. No late submissions will be accepted.

Instructions: Submit your answers to these questions to the Curator as OQ02 by the posted due date and time. No late submissions will be accepted. Instructions: Submit your answers to these questions to the Curator as OQ02 by the posted due date and time. No late submissions will be accepted. For the next five questions, consider the function to

More information

Concurrency, Thread. Dongkun Shin, SKKU

Concurrency, Thread. Dongkun Shin, SKKU Concurrency, Thread 1 Thread Classic view a single point of execution within a program a single PC where instructions are being fetched from and executed), Multi-threaded program Has more than one point

More information

C Grundlagen - Threads

C Grundlagen - Threads Michael Strassberger saremox@linux.com Proseminar C Grundlagen Fachbereich Informatik Fakultaet fuer Mathematik, Informatik und Naturwissenschaften Universitaet Hamburg 3. Juli 2014 Table of Contents 1

More information

Exam 3 Chapters 7 & 9

Exam 3 Chapters 7 & 9 Exam 3 Chapters 7 & 9 CSC 2100-002/003 29 Mar 2017 Read through the entire test first BEFORE starting Put your name at the TOP of every page The test has 4 sections worth a total of 100 points o True/False

More information

CS 3305 Intro to Threads. Lecture 6

CS 3305 Intro to Threads. Lecture 6 CS 3305 Intro to Threads Lecture 6 Introduction Multiple applications run concurrently! This means that there are multiple processes running on a computer Introduction Applications often need to perform

More information

CS333 Intro to Operating Systems. Jonathan Walpole

CS333 Intro to Operating Systems. Jonathan Walpole CS333 Intro to Operating Systems Jonathan Walpole Threads & Concurrency 2 Threads Processes have the following components: - an address space - a collection of operating system state - a CPU context or

More information

Thread. Disclaimer: some slides are adopted from the book authors slides with permission 1

Thread. Disclaimer: some slides are adopted from the book authors slides with permission 1 Thread Disclaimer: some slides are adopted from the book authors slides with permission 1 IPC Shared memory Recap share a memory region between processes read or write to the shared memory region fast

More information

Shared Memory Programming: Threads and OpenMP. Lecture 6

Shared Memory Programming: Threads and OpenMP. Lecture 6 Shared Memory Programming: Threads and OpenMP Lecture 6 James Demmel www.cs.berkeley.edu/~demmel/cs267_spr16/ CS267 Lecture 6 1 Outline Parallel Programming with Threads Parallel Programming with OpenMP

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 22 Shared-Memory Concurrency 1 Administrivia HW7 due Thursday night, 11 pm (+ late days if you still have any & want to use them) Course

More information

CSE409, Rob Johnson, Alin Tomescu, November 11 th, 2011 Buffer overflow defenses

CSE409, Rob Johnson,   Alin Tomescu, November 11 th, 2011 Buffer overflow defenses Buffer overflow defenses There are two categories of buffer-overflow defenses: - Make it hard for the attacker to exploit buffer overflow o Address space layout randomization o Model checking to catch

More information

Threaded Programming. Lecture 9: Alternatives to OpenMP

Threaded Programming. Lecture 9: Alternatives to OpenMP Threaded Programming Lecture 9: Alternatives to OpenMP What s wrong with OpenMP? OpenMP is designed for programs where you want a fixed number of threads, and you always want the threads to be consuming

More information

AstréeA From Research To Industry

AstréeA From Research To Industry AstréeA From Research To Industry Dr.-Ing. Stephan Wilhelm, AbsInt GmbH Workshop on Static Analysis of Concurrent Software Edinburgh, 2016 2 AbsInt Angewandte Informatik GmbH Provides advanced development

More information

Exception Safe Coding

Exception Safe Coding Exception Safe Coding Dirk Hutter hutter@compeng.uni-frankfurt.de Prof. Dr. Volker Lindenstruth FIAS Frankfurt Institute for Advanced Studies Goethe-Universität Frankfurt am Main, Germany http://compeng.uni-frankfurt.de

More information

IV. Process Synchronisation

IV. Process Synchronisation IV. Process Synchronisation Operating Systems Stefan Klinger Database & Information Systems Group University of Konstanz Summer Term 2009 Background Multiprogramming Multiple processes are executed asynchronously.

More information

CS152: Programming Languages. Lecture 19 Shared-Memory Parallelism and Concurrency. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 19 Shared-Memory Parallelism and Concurrency. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 19 Shared-Memory Parallelism and Concurrency Dan Grossman Spring 2011 Concurrency and Parallelism PL support for concurrency/parallelism a huge topic Increasingly important

More information

Relaxed Memory: The Specification Design Space

Relaxed Memory: The Specification Design Space Relaxed Memory: The Specification Design Space Mark Batty University of Cambridge Fortran meeting, Delft, 25 June 2013 1 An ideal specification Unambiguous Easy to understand Sound w.r.t. experimentally

More information

Concurrency and Parallelism. CS152: Programming Languages. Lecture 19 Shared-Memory Parallelism and Concurrency. Concurrency vs. Parallelism.

Concurrency and Parallelism. CS152: Programming Languages. Lecture 19 Shared-Memory Parallelism and Concurrency. Concurrency vs. Parallelism. CS152: Programming Languages Lecture 19 Shared-Memory Parallelism and Concurrency Dan Grossman Spring 2011 Concurrency and Parallelism PL support for concurrency/parallelism a huge topic Increasingly important

More information

Motivation & examples Threads, shared memory, & synchronization

Motivation & examples Threads, shared memory, & synchronization 1 Motivation & examples Threads, shared memory, & synchronization How do locks work? Data races (a lower level property) How do data race detectors work? Atomicity (a higher level property) Concurrency

More information

Parallel Programming with OpenMP. CS240A, T. Yang

Parallel Programming with OpenMP. CS240A, T. Yang Parallel Programming with OpenMP CS240A, T. Yang 1 A Programmer s View of OpenMP What is OpenMP? Open specification for Multi-Processing Standard API for defining multi-threaded shared-memory programs

More information

The Rule of Constancy(Derived Frame Rule)

The Rule of Constancy(Derived Frame Rule) The Rule of Constancy(Derived Frame Rule) The following derived rule is used on the next slide The rule of constancy {P } C {Q} {P R} C {Q R} where no variable assigned to in C occurs in R Outline of derivation

More information

Separation Logic: syntax, semantics and calculus

Separation Logic: syntax, semantics and calculus Separation Logic: syntax, semantics and calculus Syntax Semantics Calculus emp SL N/A FOL N/A = + Arithmetic N/A := ; while if then else [.] dispose(.) cons(.) State is a pair (Store,Heap) St(.) maps variables

More information

Effective Performance Measurement and Analysis of Multithreaded Applications

Effective Performance Measurement and Analysis of Multithreaded Applications Effective Performance Measurement and Analysis of Multithreaded Applications Nathan Tallent John Mellor-Crummey Rice University CSCaDS hpctoolkit.org Wanted: Multicore Programming Models Simple well-defined

More information

Synchronization. CS61, Lecture 18. Prof. Stephen Chong November 3, 2011

Synchronization. CS61, Lecture 18. Prof. Stephen Chong November 3, 2011 Synchronization CS61, Lecture 18 Prof. Stephen Chong November 3, 2011 Announcements Assignment 5 Tell us your group by Sunday Nov 6 Due Thursday Nov 17 Talks of interest in next two days Towards Predictable,

More information

Formal Methods for Java

Formal Methods for Java Formal Methods for Java Lecture 30: Conclusion Jochen Hoenicke Software Engineering Albert-Ludwigs-University Freiburg Feb 17, 2012 Jochen Hoenicke (Software Engineering) FM4J Feb 17, 2012 1 / 21 Topics

More information

pthreads CS449 Fall 2017

pthreads CS449 Fall 2017 pthreads CS449 Fall 2017 POSIX Portable Operating System Interface Standard interface between OS and program UNIX-derived OSes mostly follow POSIX Linux, macos, Android, etc. Windows requires separate

More information

Concurrency and Synchronization. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

Concurrency and Synchronization. ECE 650 Systems Programming & Engineering Duke University, Spring 2018 Concurrency and Synchronization ECE 650 Systems Programming & Engineering Duke University, Spring 2018 Concurrency Multiprogramming Supported by most all current operating systems More than one unit of

More information

FAKULTÄT FÜR INFORMATIK

FAKULTÄT FÜR INFORMATIK FAKULTÄT FÜR INFORMATIK DER TECHNISCHEN UNIVERSITÄT MÜNCHEN Master-Seminar Software Verification Author: Lukas Erlacher Advisor: Prof. Andrey Rybalchenko, Dr. Corneliu Popeea Submission: April, 2013 Contents

More information

POSIX PTHREADS PROGRAMMING

POSIX PTHREADS PROGRAMMING POSIX PTHREADS PROGRAMMING Download the exercise code at http://www-micrel.deis.unibo.it/~capotondi/pthreads.zip Alessandro Capotondi alessandro.capotondi(@)unibo.it Hardware Software Design of Embedded

More information

Taming release-acquire consistency

Taming release-acquire consistency Taming release-acquire consistency Ori Lahav Nick Giannarakis Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS) POPL 2016 Weak memory models Weak memory models provide formal sound semantics

More information

Type Soundness and Race Freedom for Mezzo

Type Soundness and Race Freedom for Mezzo Type Soundness and Race Freedom for Mezzo Thibaut Balabonski François Pottier Jonathan Protzenko INRIA FLOPS 2014 1 / 42 Mezzo in a few words Mezzo is a high-level programming language, equipped with:

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Nondeterminism is Unavoidable, but Data Races are Pure Evil

Nondeterminism is Unavoidable, but Data Races are Pure Evil Nondeterminism is Unavoidable, but Data Races are Pure Evil Hans-J. Boehm HP Labs 5 November 2012 1 Low-level nondeterminism is pervasive E.g. Atomically incrementing a global counter is nondeterministic.

More information

Compilation and Program Analysis (#11) : Hoare triples and shape analysis

Compilation and Program Analysis (#11) : Hoare triples and shape analysis Compilation and Program Analysis (#11) : Hoare triples and shape analysis Laure Gonnord http://laure.gonnord.org/pro/teaching/capm1.html Laure.Gonnord@ens-lyon.fr Master 1, ENS de Lyon dec 2017 Inspiration

More information

Programming Languages

Programming Languages TECHNISCHE UNIVERSITÄT MÜNCHEN FAKULTÄT FÜR INFORMATIK Programming Languages Concurrency: Atomic Executions, Locks and Monitors Dr. Michael Petter Winter term 2016 Atomic Executions, Locks and Monitors

More information

Typed Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts

Typed Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts Typed Assembly Language for Implementing OS Kernels in SMP/Multi-Core Environments with Interrupts Toshiyuki Maeda and Akinori Yonezawa University of Tokyo Quiz [Environment] CPU: Intel Xeon X5570 (2.93GHz)

More information

Atomic operations in C

Atomic operations in C Atomic operations in C Sergey Vojtovich Software Engineer @ MariaDB Foundation * * Agenda API overview details, examples, common mistakes a few words about volatile Rationale Atomic operations are intended

More information

Programmin Languages/Variables and Storage

Programmin Languages/Variables and Storage Programmin Languages/Variables and Storage Onur Tolga Şehitoğlu Computer Engineering 4 Mart 2007 Outline 1 Storage Array Variables 2 Semantics of Assignment 3 Variable Lifetime Global Lifetime Local Lifetime

More information

Formal Verification Techniques for GPU Kernels Lecture 1

Formal Verification Techniques for GPU Kernels Lecture 1 École de Recherche: Semantics and Tools for Low-Level Concurrent Programming ENS Lyon Formal Verification Techniques for GPU Kernels Lecture 1 Alastair Donaldson Imperial College London www.doc.ic.ac.uk/~afd

More information

Allows program to be incrementally parallelized

Allows program to be incrementally parallelized Basic OpenMP What is OpenMP An open standard for shared memory programming in C/C+ + and Fortran supported by Intel, Gnu, Microsoft, Apple, IBM, HP and others Compiler directives and library support OpenMP

More information

Part 3: Beyond Reduction

Part 3: Beyond Reduction Lightweight Analyses For Reliable Concurrency Part 3: Beyond Reduction Stephen Freund Williams College joint work with Cormac Flanagan (UCSC), Shaz Qadeer (MSR) Busy Acquire Busy Acquire void busy_acquire()

More information

Multithreading and Interactive Programs

Multithreading and Interactive Programs Multithreading and Interactive Programs CS160: User Interfaces John Canny. This time Multithreading for interactivity need and risks Some design patterns for multithreaded programs Debugging multithreaded

More information

1 of 6 Lecture 7: March 4. CISC 879 Software Support for Multicore Architectures Spring Lecture 7: March 4, 2008

1 of 6 Lecture 7: March 4. CISC 879 Software Support for Multicore Architectures Spring Lecture 7: March 4, 2008 1 of 6 Lecture 7: March 4 CISC 879 Software Support for Multicore Architectures Spring 2008 Lecture 7: March 4, 2008 Lecturer: Lori Pollock Scribe: Navreet Virk Open MP Programming Topics covered 1. Introduction

More information

Lindsay Groves, Simon Doherty. Mark Moir, Victor Luchangco

Lindsay Groves, Simon Doherty. Mark Moir, Victor Luchangco Lindsay Groves, Simon Doherty Victoria University of Wellington Mark Moir, Victor Luchangco Sun Microsystems, Boston (FORTE, Madrid, September, 2004) Lock-based concurrency doesn t scale Lock-free/non-blocking

More information

Shared Memory Parallel Programming with Pthreads An overview

Shared Memory Parallel Programming with Pthreads An overview Shared Memory Parallel Programming with Pthreads An overview Part II Ing. Andrea Marongiu (a.marongiu@unibo.it) Includes slides from ECE459: Programming for Performance course at University of Waterloo

More information

HPCSE - I. «Introduction to multithreading» Panos Hadjidoukas

HPCSE - I. «Introduction to multithreading» Panos Hadjidoukas HPCSE - I «Introduction to multithreading» Panos Hadjidoukas 1 Processes and Threads POSIX Threads API Outline Thread management Synchronization with mutexes Deadlock and thread safety 2 Terminology -

More information

C++ Memory Model Tutorial

C++ Memory Model Tutorial C++ Memory Model Tutorial Wenzhu Man C++ Memory Model Tutorial 1 / 16 Outline 1 Motivation 2 Memory Ordering for Atomic Operations The synchronizes-with and happens-before relationship (not from lecture

More information

Determining the Fundamental Basis of Software Vulnerabilities. Larry Wagoner NSA

Determining the Fundamental Basis of Software Vulnerabilities. Larry Wagoner NSA Determining the Fundamental Basis of Software Vulnerabilities Larry Wagoner NSA Agenda Background Analogous background Matt Bishop work CWEs Tool reporting of CWEs KDM Analytics Determining the fundamental

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

More information

POSIX Threads and OpenMP tasks

POSIX Threads and OpenMP tasks POSIX Threads and OpenMP tasks Jimmy Aguilar Mena February 16, 2018 Introduction Pthreads Tasks Two simple schemas Independent functions # include # include void f u n c t i

More information

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C

An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C An Operational and Axiomatic Semantics for Non-determinism and Sequence Points in C Robbert Krebbers Radboud University Nijmegen January 22, 2014 @ POPL, San Diego, USA 1 / 16 What is this program supposed

More information

Distributed Systems. Distributed Shared Memory. Paul Krzyzanowski

Distributed Systems. Distributed Shared Memory. Paul Krzyzanowski Distributed Systems Distributed Shared Memory Paul Krzyzanowski pxk@cs.rutgers.edu Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.

More information

7/6/2015. Motivation & examples Threads, shared memory, & synchronization. Imperative programs

7/6/2015. Motivation & examples Threads, shared memory, & synchronization. Imperative programs Motivation & examples Threads, shared memory, & synchronization How do locks work? Data races (a lower level property) How do data race detectors work? Atomicity (a higher level property) Concurrency exceptions

More information

Shared Memory. SMP Architectures and Programming

Shared Memory. SMP Architectures and Programming Shared Memory SMP Architectures and Programming 1 Why work with shared memory parallel programming? Speed Ease of use CLUMPS Good starting point 2 Shared Memory Processes or threads share memory No explicit

More information

Order Is A Lie. Are you sure you know how your code runs?

Order Is A Lie. Are you sure you know how your code runs? Order Is A Lie Are you sure you know how your code runs? Order in code is not respected by Compilers Processors (out-of-order execution) SMP Cache Management Understanding execution order in a multithreaded

More information

Multithreading and Interactive Programs

Multithreading and Interactive Programs Multithreading and Interactive Programs CS160: User Interfaces John Canny. Last time Model-View-Controller Break up a component into Model of the data supporting the App View determining the look of the

More information

Operational Semantics of Cool

Operational Semantics of Cool Operational Semantics of Cool Key Concepts semantics: the meaning of a program, what does program do? how the code is executed? operational semantics: high level code generation steps of calculating values

More information

Multicore Programming: C++0x

Multicore Programming: C++0x p. 1 Multicore Programming: C++0x Mark Batty University of Cambridge in collaboration with Scott Owens, Susmit Sarkar, Peter Sewell, Tjark Weber November, 2010 p. 2 C++0x: the next C++ Specified by the

More information

Lecture 5. Towards a Verifying Compiler: Multithreading

Lecture 5. Towards a Verifying Compiler: Multithreading Lecture 5 Towards a Verifying Compiler: Multithreading W olfram Schulte Microsoft Research Formal Methods 2006 Race Conditions, Locks, Deadlocks, Invariants, Locklevels Access Sets Joint work with Rustan

More information

Introduction to pthreads

Introduction to pthreads CS 220: Introduction to Parallel Computing Introduction to pthreads Lecture 25 Threads In computing, a thread is the smallest schedulable unit of execution Your operating system has a scheduler that decides

More information

ENCM 501 Winter 2019 Assignment 9

ENCM 501 Winter 2019 Assignment 9 page 1 of 6 ENCM 501 Winter 2019 Assignment 9 Steve Norman Department of Electrical & Computer Engineering University of Calgary April 2019 Assignment instructions and other documents for ENCM 501 can

More information

Hiding local state in direct style: a higher-order anti-frame rule

Hiding local state in direct style: a higher-order anti-frame rule 1 / 65 Hiding local state in direct style: a higher-order anti-frame rule François Pottier January 28th, 2008 2 / 65 Contents Introduction Basics of the type system A higher-order anti-frame rule Applications

More information

High-level languages

High-level languages High-level languages High-level languages are not immune to these problems. Actually, the situation is even worse: the source language typically operates over mixed-size values (multi-word and bitfield);

More information

Parallel Programming Patterns Overview CS 472 Concurrent & Parallel Programming University of Evansville

Parallel Programming Patterns Overview CS 472 Concurrent & Parallel Programming University of Evansville Parallel Programming Patterns Overview CS 472 Concurrent & Parallel Programming of Evansville Selection of slides from CIS 410/510 Introduction to Parallel Computing Department of Computer and Information

More information

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts. CPSC/ECE 3220 Fall 2017 Exam 1 Name: 1. Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.) Referee / Illusionist / Glue. Circle only one of R, I, or G.

More information

CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing

CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing CSCI-1200 Data Structures Fall 2009 Lecture 25 Concurrency & Asynchronous Computing Final Exam General Information The final exam will be held Monday, Dec 21st, 2009, 11:30am-2:30pm, DCC 308. A makeup

More information

Introduction to Parallel Programming Part 4 Confronting Race Conditions

Introduction to Parallel Programming Part 4 Confronting Race Conditions Introduction to Parallel Programming Part 4 Confronting Race Conditions Intel Software College Objectives At the end of this module you should be able to: Give practical examples of ways that threads may

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

A separation logic for a promising semantics

A separation logic for a promising semantics A separation logic for a promising semantics Kasper Svendsen, Jean Pichon-Pharabod 1, Marko Doko 2, Ori Lahav 3, and Viktor Vafeiadis 2 1 University of Cambridge 2 MPI-SWS 3 Tel Aviv University Abstract.

More information

Hierarchical Pointer Analysis

Hierarchical Pointer Analysis for Distributed Programs Amir Kamil and Katherine Yelick U.C. Berkeley August 23, 2007 1 Amir Kamil Background 2 Amir Kamil Hierarchical Machines Parallel machines often have hierarchical structure 4 A

More information