Top Banner
Erlang Embedded Concurrent Blinkenlights and More! Omer Kilic || @OmerK [email protected]
26

Erlang Embedded — Concurrent Blinkenlights and More!

May 13, 2015

Download

Documents

Omer Kilic
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Erlang Embedded — Concurrent Blinkenlights and More!

Erlang EmbeddedConcurrent Blinkenlights and More!

Omer Kilic || @[email protected]

Page 2: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 2/26

Agenda

● Challenges in Modern Embedded Systems● Overview of Erlang● Erlang Embedded● Q & A

Page 3: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 3/26

Challenges in Embedded Systems (I)

● Larger, more complex systems than ever before● Multi-core processing

● Harder to develop for using the standard embedded development flow

● Harder to utilise the full processing potential● Much harder to debug (and fix!)

Page 4: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 4/26

Challenges in Embedded Systems (II)

● Increasingly higher degrees of heterogeneity in terms of:● Cores● Hardware acceleration (GPU, co-processor etc)● Interconnect● Memory hierarchies

Page 5: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 5/26

Internet of Things (I)

Page 6: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 6/26

Internet of Things (II)

http://blogs.cisco.com/news/the-internet-of-things-infographic/

Page 7: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 7/26

Erlang?● {functional, concurrent/parallel, garbage-collected,

soft real-time, fault-tolerant, distributed, message-passing}

● First version developed in 1986● Open-sourced in 1998.

● Battle-tested at Ericsson and many other companies● Originally designed for Embedded Systems!

Page 8: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 8/26

Erlang Advantage (I)

● Declarative● Functional programming language, high abstraction

level, concise readable programs.● Concurrent and Parallel

● Highly scalable, transparent or explicit concurrency, lightweight processes. Takes full advantage of multicore architectures.

Page 9: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 9/26

Erlang Advantage (II)

● Robust● Simple and consistent error recovery and supervision

hierarchies, built-in fault tolerance.● Portable, Distributed

● Runs on a variety of platforms, network-aware runtime, supports heterogeneous networks.

Page 10: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 10/26

Erlang Advantage (III)

● External Interfaces● NIFs and ports used to interface external world to the

Erlang runtime.● Soft Real-Time

● Response time (can be) in the order of milliseconds, per-process garbage collection.

● Hot-code loading● Dynamic reconfiguration.

Page 11: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 11/26

Erlang, the Maestro

(flickr/dereckesanches)

Page 12: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 12/26

External Interfaces● Native Implemented Functions (NIFs) and ports

used to interface external world to the Erlang runtime.

app

hw_if hw_driver.c

Erlang VM

Page 13: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 13/26

#include “stats.h”

Source: http://embedded.com/electronics-blogs/programming-pointers/4372180/Unexpected-trends

Page 14: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 14/26

Actor Model● Proposed in 1973 by Hewitt, Bishop, and Steiger

● “Universal primitives of concurrent computation”● Building blocks for modular, distributed and concurrent

systems● No shared-state, self-contained and atomic● Implemented in a variety of programming languages

● Erlang, Scala (AKKA), Java (Kilim), Ruby (Celluloid), C++11 (libcppa)

Page 15: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 15/26

Actor Model● Asynchronous message passing

● Messages kept in a mailbox and processes in the order they are received in

● Upon receiving a message, actors can:● Make local decisions and change internal state● Spawn new actors● Send messages to other actors

functionality

mailbox

state

Page 16: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 16/26

Example: GPIO

GPIO

proc_a

pin17

{init, 17, output}

Page 17: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 17/26

Example: GPIO

GPIO

proc_a

pin17

{state, 17, high}

proc_b

{state, 1

7, low}

proc_c

{state, 17, high}

Page 18: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 18/26

GPIO “Proxy”● Replaces the “locks” in traditional sense of

embedded design● Access control/mutual exclusion

● Can be used to implement safety constraints● Toggling rate, sequence detection, direction control,

etc.

Page 19: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 19/26

TI OMAP Reference System

Page 20: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 20/26

Fine Grain Abstraction● Advantages

● Application code becomes simpler– Concise and shorter modules– Testing becomes easier– Code re-use (potentially) increases

● Disadvantages● Architecting fine grain systems is difficult

Page 21: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 21/26

Erlang Embedded

“The aim of this KTP project is to bring the benefits of concurrent systems

development using Erlang to the field of embedded systems; through investigation, analysis, software development and evaluation."

Page 22: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 22/26

Hardware Projects

Page 23: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 23/26

Future ExplorationsParallella!

Page 24: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 24/26

Interested in Erlang?● http://www.erlang.org/doc/● http://learnyousomeerlang.com/

http://www.youtube.com/watch?v=xrIjfIjssLE :)

Page 25: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 25/26

Erlang Embedded Training Stack

● A complete package for people interested in developing the next generation of concurrent/distributed Embedded Systems

● Training Modules● Embedded Linux Primer● Erlang/OTP 101● Erlang Embedded Framework

● Hardware included!

Erlang Embedded Framework

Erlang/OTP 101

Embedded Linux Primer

Hardware Platform

Page 26: Erlang Embedded — Concurrent Blinkenlights and More!

15/11/2012 Open Source Hardware User Group Meetup #22 Slide 26/26

Thank you

● www.erlang-embedded.com● [email protected] ● @ErlangEmbedded

Any sufficiently complicated concurrent program in another language contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Erlang.

– Robert VirdingCo-Inventor of Erlang