An introduction to F# (part 2) Bogdan Brinzarea-Iamandi Banca Romaneasca 25 February 2010.

Slides:



Advertisements
Similar presentations
Introduction to Concurrency in F# Joey Dodds. F# F# Warmup F# async basics async let! examples Continuations Events.
Advertisements

Parallel Extensions to the.NET Framework Daniel Moth Microsoft
Concurrency The need for speed. Why concurrency? Moore’s law: 1. The number of components on a chip doubles about every 18 months 2. The speed of computation.
Parasol Architecture A mild case of scary asynchronous system stuff.
Async Programming WITH ASYNC TASK
Computer Systems/Operating Systems - Class 8
Intro to Threading CS221 – 4/20/09. What we’ll cover today Finish the DOTS program Introduction to threads and multi-threading.
Task Scheduling and Distribution System Saeed Mahameed, Hani Ayoub Electrical Engineering Department, Technion – Israel Institute of Technology
CS533 Concepts of Operating Systems Class 20 Summary.
490dp Synchronous vs. Asynchronous Invocation Robert Grimm.
Virtual techdays INDIA │ 9-11 February 2011 Parallelism in.NET 4.0 Parag Paithankar │ Technology Advisor - Web, Microsoft India.
Erlang concurrency. Where were we? Finished talking about sequential Erlang Left with two questions  retry – not an issue; I mis-read the statement in.
1: Operating Systems Overview
CS533 Concepts of Operating Systems Class 6 The Duality of Threads and Events.
Reactive Programming with F# Tomáš Petříček Microsoft C# MVP
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
CS533 Concepts of Operating Systems Class 2 Thread vs Event-Based Programming.
CS533 Concepts of Operating Systems Class 2 The Duality of Threads and Events.
CS603 Communication Mechanisms 14 January Types of Communication Shared Memory Message Passing Stream-oriented Communications Remote Procedure Call.
Introduction. Why Study OS? Understand model of operation –Easier to see how to use the system –Enables you to write efficient code Learn to design an.
Parallel Programming in.NET Kevin Luty.  History of Parallelism  Benefits of Parallel Programming and Designs  What to Consider  Defining Types of.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
Lecture 4: Parallel Programming Models. Parallel Programming Models Parallel Programming Models: Data parallelism / Task parallelism Explicit parallelism.
© 2011 Autodesk Single Job 1 Processor 1 Single Job 2 Single Job 3 Processor 2 Processor 3 Big Job 1 Big Job 2 Single Job 4 Processor 1 Single Job 5 Single.
© 2009 Matthew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen 1 Concurrency in Programming Languages Matthew J. Sottile Timothy G. Mattson Craig.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
ICOM 5995: Performance Instrumentation and Visualization for High Performance Computer Systems Lecture 7 October 16, 2002 Nayda G. Santiago.
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
An introduction to F# Bogdan Brinzarea-Iamandi Banca Romaneasca 22 February 2010.
Reactive Extensions Ye olde introduction and walk-through, with plenty o’ code.
Workflow Early Start Pattern and Future's Update Strategies in ProActive Environment E. Zimeo, N. Ranaldo, G. Tretola University of Sannio - Italy.
SIMPLE PARALLEL PROGRAMMING WITH PATTERNS AND OMNITHREADLIBRARY PRIMOŽ GABRIJELČIČ SKYPE: GABR42
Robert Vitolo CS474.  Branched off of ML (metalanguage)  Developed at Microsoft, available as part of the Visual Studio 2010 software package, integrated.
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
The Vesta Parallel File System Peter F. Corbett Dror G. Feithlson.
Programming Paradigms for Concurrency Pavol Cerny Vasu Singh Thomas Wies Part III – Message Passing Concurrency.
Reactive pattern matching for F# Part of “Variations in F#” research project Tomáš Petříček, Charles University in Prague
1 Object Oriented Logic Programming as an Agent Building Infrastructure Oct 12, 2002 Copyright © 2002, Paul Tarau Paul Tarau University of North Texas.
Implementing Remote Procedure Calls Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Published: ACM Transactions on Computer Systems,
Concurrent Object-Oriented Programming Languages Chris Tomlinson Mark Scheevel.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
The Inverse World of the FOREST Object Web Duncan Cragg Part 1 - Overview.
Patterns of Parallel Programming with.NET 4 Stephen Toub Principal Architect Parallel Computing Platform Microsoft Corporation
CHAPTER 6 Threads, Handlers, and Programmatic Movement.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
THE FUTURE OF C#: GOOD THINGS COME TO THOSE WHO ‘AWAIT’ Joseph Albahari SESSION CODE: DEV411 (c) 2011 Microsoft. All rights reserved.
TensorFlow– A system for large-scale machine learning
Miraj Kheni Authors: Toyotaro Suzumura, Koji Ueno
Why Events Are A Bad Idea (for high-concurrency servers)
The Mach System Sri Ramkrishna.
Advanced Topics in Concurrency and Reactive Programming: Asynchronous Programming Majeed Kassis.
Async or Parallel? No they aren’t the same thing!
Setac: A Phased Deterministic Testing Framework for Scala Actors
Staying Afloat in the .NET Async Ocean
Chapter 4: Threads.
12 Asynchronous Programming
Lecture 21: Introduction to Process Scheduling
Transactional Memory Semaphores, monitors, and conditional critical regions all suffer from limitations based on lock semantics Naïve synchronization may.
F# for Parallel and Asynchronous Programming
Android Topics Asynchronous Callsbacks
Background and Motivation
Enable long running Function Orchestrations
Lecture 21: Introduction to Process Scheduling
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Chapter 6: Architectural Design
CMSC 202 Threads.
Presentation transcript:

An introduction to F# (part 2) Bogdan Brinzarea-Iamandi Banca Romaneasca 25 February 2010

TopicCovered Today History22 february 2010 From imperative to functional22 february 2010 Fundamentals22 february 2010 Data structures22 february 2010 Pattern Matching22 february 2010 Immutability vs. Mutability22 february 2010 Object Oriented Programming22 february 2010 Async and Parallel Programming Unit testing

ProblemSolution I/O bound applicationAsynchronous processing CPU bound applicationParallel and distributed processing Freezing UIAsynchronous processing Sharing stateImmutability

 Working with threads is difficult  Synchronizing and sharing state are difficult  Introducing bugs is easy  The code is complicated

 Multiple active evaluations (threads computing results)  Multiple pending reactions (callbacks and agents waiting for events and messages)

 Not useful for asynchronous operations  Imperative programming  Sharing mutable data between threads  Cancellations  Raising events in the right thread

 Optimization opportunities  Easily transferable between threads  Reliability

 Ease of change  Cancellation checking  Simple resource management  Exception propagation

 Creates async objects  These tasks can be run  In the current thread  In a background thread  In parallel using fork/join mechanism  As continuations

 Takes async objects and creates async tasks  Uses QueueUserWorkItem  Fork/join pattern  Does not report progress seq > -> Async

 Runs synchronous computation  Waits for the result  Batch processing jobs  Matrix multiplication

 Starts and ends in the same thread  Useful for UI updating  Continuations for:  Complete  Exception  Cancellation

 let! for async method calls  The thread is suspended until the result in available  The rest of the code runs as a continuation  use! resource disposing equivalent of let!

 Leverage parallel hardware capabilities  Data parallel programming with PLinq  Easy to implement  Abstracts away complexity  Transparent partition and merge operations  Works on seq and IEnumerable  Task parallel programming using the new Task Parallel Library in.NET 4.0

 Erlang message passing style  “An actor is a computational entity that, in response to a message it receives, can concurrently: ▪ send a finite number of messages to other actors; ▪ create a finite number of new actors; ▪ designate the behavior to be used for the next message it receives.”

 Asynchronous message passing  Can have even 1000 agents  Agents are lightweight  Based on async programming  State isolation between agents  No concurrency and data races

 NUnit  xUnit.net

 FsUnit based on NUnit  FsCheck inspired from Haskell’s QuickCheck  FsTest based on xUnit.net  NaturalSpec based on NUnit  FsSpec readable DSL

 Expert F# by Don Syme  Programming F# by Chris Smith  CTO Corner -  HubFS  Matthew Podwysocki  Don Syme  Chris Smith