SXM: Software Transactional Memory in C# Maurice Herlihy.

Slides:



Advertisements
Similar presentations
Linked Lists Geletaw S..
Advertisements

Software Transactional Objects Guy Eddon Maurice Herlihy TRAMP 2007.
Section 2.5 Single-Linked Lists. A linked list is useful for inserting and removing at arbitrary locations The ArrayList is limited because its add and.
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Software Transactional Memory and Conditional Critical Regions Word-Based Systems.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Inheritance Inheritance Reserved word protected Reserved word super
Lecture 3 Feb 4 summary of last week’s topics and review questions (handout) Today’s goals: Chapter 1 overview (sections 1.4 to 1.6) c++ classes constructors,
CS 106 Introduction to Computer Science I 04 / 30 / 2007 Last lecture :( Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 12 / 04 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 12 / 06 / 2006 Instructor: Michael Eckmann.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Immutable Objects and Classes.
Lecture 27 Exam outline Boxing of primitive types in Java 1.5 Generic types in Java 1.5.
1 Data Structures Data Structures Topic #2. 2 Today’s Agenda Data Abstraction –Given what we talked about last time, we need to step through an example.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Ch 13. Features Found Only in Java Timothy Budd Oregon State University.
Java CourseWinter 2009/10. Introduction Object oriented, imperative programming language. Developed: Inspired by C++ programming language.
C++ fundamentals.
GOOD PRACTICES & STRATEGY. Functional Analysis & Approach Start from outcome onwards Simplicity Validity.
Programming Languages and Paradigms Object-Oriented Programming.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Software Transactional Memory for Dynamic-Sized Data Structures Maurice Herlihy, Victor Luchangco, Mark Moir, William Scherer Presented by: Gokul Soundararajan.
1 Exercise /* A lockbox can be open or closed. If closed, only a valid password will open the box. Once the box is open, the contents can be retrieved.
Copyright © 2006 Thomas P. Skinner1 Chapter 5 Indexers, Interfaces, and Enumerators.
Data Abstraction CS 201j: Engineering Software University of Virginia Computer Science Nathanael Paul
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
CS 106 Introduction to Computer Science I 04 / 25 / 2008 Instructor: Michael Eckmann.
Chapter 7: Pinball Game Construction Kit. Vectors Example of a “collection class” Must “import java.util.Vector” More flexible than arrays: will grow.
CSC 142 D 1 CSC 142 Instance methods [Reading: chapter 4]
Programming in Java CSCI-2220 Object Oriented Programming.
Object Oriented Software Development
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Writing a Run Time DLL The application loads the DLL using LoadLibrary() or LoadLibraryEx(). The standard search sequence is used by the operating system.
Types in programming languages1 What are types, and why do we need them?
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
Why STMs Need Compilers (a war story) Maurice Herlihy Brown University.
A Doubly Linked List prevnextdata There’s the need to access a list in reverse order header dnode.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
CIS 199 Final Review. New Material Structures  Value type  NOT a reference type!  Used to encapsulate small groups of related variables.
M1G Introduction to Programming 2 5. Completing the program.
CIS 199 Final Review. New Material Classes  Reference type  NOT a value type!  Can only inherit from ONE base class.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Linked List.  Is a series of connected nodes, where each node is a data structure with data and pointer(s) Advantages over array implementation  Can.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
CS 3180 (Prasad)L67Classes1 Classes and Interfaces Inheritance Polymorphism.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
R 1 Transactional abstractions: beyond atomic update Tim Harris r.
Value Types. 2 Objectives Discuss concept of value types –efficiency –memory management –value semantics –boxing –unboxing –simple types Introduce struct.
Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III
Modern Programming Tools And Techniques-I
More Sophisticated Behavior
Module 5: Common Type System
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
CS360 Windows Programming
Linked Lists.
Maurice Herlihy, Victor Luchangco, Mark Moir, William N. Scherer III
Cs212: Data Structures Computer Science Department Lab 7: Stacks.
CIS 199 Final Review.
CIS 199 Final Review.
CIS 199 Test 1 Review.
Lecture 10 Concepts of Programming Languages
Corresponds with Chapter 5
Presentation transcript:

SXM: Software Transactional Memory in C# Maurice Herlihy

2 Prior STM Work Awkward user interface –Long-lived transactional “wrappers” vs –Short-lived “versions” Programmer conventions –List element points to wrapper which points to list …. –Don’t use short-lived objects beyond lifetime ….

3 public class List { public int item; public TMObject next; } Old-School Atomic Classes Next field is explicit wrapper

4 List next = list.next.OpenRead(); Old-School Atomic Classes Explicit open (specify read or write)

5 List next = list.next.OpenRead(); Old-School Atomic Classes Must discard after transaction, don’t modify, etc…

6 List rVersion = list.next.OpenRead(); Old-School Atomic Classes Read version unchanged Read version changed List wVersion = list.next.OpenWrite(); wVersion.item++; List wVersion = list.next.OpenWrite(); List rVersion = list.next.OpenRead();

7 Software Transactional Memory Current Work Rewriting STM from scratch in C# Use Reflection.Emit to provide reasonable user interface Ability to generate code at run-time opens up new possibilities …

8 [Atomic] public class List { private int item; private List next; } Atomic Classes in SXM Declare “Atomic” property

9 [Atomic] public class List { private int item; private List next; } Atomic Classes in SXM Declare fields private No explicit wrapper!

10 public class List { private int item; private List next; public virtual int Item { get { return this.item; } set { this.item = value; } } C# Properties

11 public class List { private int item; private List next; public virtual int Item { get { return this.item; } set { this.item = value; } } C# Properties Wrap each field in a public virtual property

12 XObjectFactory listFactory = new XObjectFactory(typeof(List)); Transactional List Generates code to intercept property get & set methods for List type

13 XObjectFactory listFactory = new XObjectFactory(typeof(List)); Transactional List Uses reflection to “walk” over type and generate synchronization wrappers for Properties

14 List list = (List)ListFactory.Create(); Transactional List Anonymous subtype of List with transparent transactional machinery

15 public override object Insert(int v) { Node prevNode = Find(v); if (prevNode.Next.Value == v) { return false; } else { Node newNode = (Node)factory.Create(v); newNode.Next = prevNode.Next; prevNode.Next = newNode; return true; } Transaction Code

16 public bool Insert(int v) { Node prevNode = Find(v); if (prevNode.Next.Value == v) { return false; } else { Node newNode = (Node)factory.Create(v); newNode.Next = prevNode.Next; prevNode.Next = newNode; return true; } Transaction Code Look like field references … actually property calls

17 public override object Insert(int v) { Node prevNode = Find(v); if (prevNode.Next.Value == v) { return false; } else { Node newNode = (Node)factory.Create(v); newNode.Next = prevNode.Next; prevNode.Next = newNode; return true; } Transaction Code Create a new node (same args as constructor)

18 Transactions: Simple C# Interface XStart insertXStart = new XStart(Insert); Create a delegate (function ptr)

19 Transactions: Simple C# Interface XStart insertXStart = new XStart(Insert); Xaction.Run(insertXStart); Run the transaction

20 Transactions in SXM No explicit retry loop –Contention manager decides when to retry failed transactions Transaction == method –Reduces scoping errors

21 In Progress Modular Retry –As in [HPJMH 05] –Requires 1 st class nested transactions Polymorphic contention managers –Easier on-the-fly switching –Communication among heterogeneous CMs