The Actor Model applied to the Raspberry Pi and the Embedded Domain
1. The Actor Model applied to the
Raspberry Pi and the
Embedded Domain
Omer Kilic || @OmerK
omer@erlang-solutions.com
2. Agenda
â˘
â˘
â˘
â˘
â˘
â˘
â˘
Current state of Embedded Systems
Overview of the Actor Model
Erlang Embedded Project
Modelling and developing systems using Erlang
Experiments with the Raspberry Pi
Future Explorations
Q&A
03/12/2012
Tech Mesh London
Slide 2 of 45
3. Embedded Systems
â
An embedded system is a computer system designed for
specific control functions within a larger system, often
with real-time computing constraints. It is embedded as
part of a complete device often including hardware and
mechanical parts. By contrast, a general-purpose
computer, such as a personal computer (PC), is designed
to be flexible and to meet a wide range of end-user needs.
- Infinite Wisdom of Wikipedia
03/12/2012
Tech Mesh London
Slide 3 of 45
5. Current Challenges
⢠Complex SoC platforms
⢠âInternet of Thingsâ
â Connected and distributed systems
⢠Multicore and/or heterogeneous devices
⢠Time to market constraints
03/12/2012
Tech Mesh London
Slide 5 of 45
6. Embedded Systems
⢠Bare Metal
â No underlying OS or high level abstractions
⢠RTOS
â Minimal interrupt and switching latency,
scheduling guarantees, minimal jitter
⢠Embedded Linux
â Slimmed down Linux with hardware interfaces
03/12/2012
Tech Mesh London
Slide 6 of 45
7. RTOS Concepts
⢠Notion of âtasksâ
⢠OS-supervised interprocess messaging
â Shared memory
⢠Mutexes/Semaphores/Locks
⢠Scheduling
â Pre-emptive: event driven
â Round-robin: time multiplexed
03/12/2012
Tech Mesh London
Slide 7 of 45
8. Embedded Linux
⢠Not a new concept, increased popularity due
to abundant supply of cheap boards
â Raspberry Pi, Beagleboard/Beaglebone, Gumstix et al.
⢠Familiar set of tools for software developers,
new territory for embedded engineers
â No direct mapping for RTOS concepts, especially
tasks
⢠Complex device driver framework
â Here be dragons
03/12/2012
Tech Mesh London
Slide 8 of 45
9. Actor Model
⢠Proposed in 1973 by Hewitt, Bishop and Steiger
â âUniversal primitives for concurrent computationâ
⢠No shared-state, self-contained and atomic
⢠Building blocks for modular, distributed and
concurrent systems
⢠Implemented in a variety of programming
languages
03/12/2012
Tech Mesh London
Slide 9 of 45
10. Actor Model
⢠Asynchronous message passing
â Messages kept in a mailbox and processed in the
order they are received in
⢠Upon receiving messages, actors can:
â Make local decisions and change internal state
â Spawn new actors
â Send messages to other actors
03/12/2012
Tech Mesh London
Slide 10 of 45
13. Limitations of the Actor Model
⢠No notion of inheritance or general hierarchy
â Specific to language and library implementation
⢠Asynchronous message passing can be
problematic for certain applications
â Ordering of messages received from multiple
processes
â Abstract definition may lead to inconsistency in
larger systems
⢠Fine/Coarse Grain argument
03/12/2012
Tech Mesh London
Slide 13 of 45
14. Erlang Embedded
⢠Knowledge Transfer Partnership between
Erlang Solutions and University of Kent
â Aim of the project: Bring the benefits of
concurrent systems development using Erlang to
the field of embedded systems; through
investigation, analysis, software development and
evaluation.
http://erlang-embedded.com
03/12/2012
Tech Mesh London
Slide 14 of 45
15. Why Erlang?
⢠Implements the Actor model
⢠Battle-tested at Ericsson and many other
companies
â Originally designed for embedded applications
⢠Support for concurrency and distributed
systems out of the box
⢠Easy to create robust systems
⢠(...and more!)
03/12/2012
Tech Mesh London
Slide 15 of 45
16. High Availability/Reliability
⢠Simple and consistent error recovery and
supervision hierarchies
⢠Built in fault-tolerance
â Isolation of Actors
⢠Support for dynamic reconfiguration
â Hot code loading
03/12/2012
Tech Mesh London
Slide 16 of 45
20. Process Error Handling
⢠Let it Fail!
â Abstract error handling away from the modules
â Results in leaner modules
⢠Supervision hierarchies
03/12/2012
Tech Mesh London
Slide 20 of 45
23. External Interfaces
⢠Native Implemented Functions (NIFs) and
ports used to interface external world to the
Erlang runtime.
03/12/2012
Tech Mesh London
Slide 23 of 45
25. Raspberry Pi
â˘
â˘
â˘
â˘
â˘
700 MHz ARM11
256 MB DDR2 RAM
10/100Mb Ethernet
2x USB 2.0
(HDMI, Composite
Video, 3.5mm
Stereo Jack, DSI,
CSI-2)
03/12/2012
$35
Tech Mesh London
Slide 25 of 45
26. Raspberry Pi in Education
⢠The Raspberry Pi Foundation is a
UK registered charity.
⢠Mission statement: "...to promote
the study of computer science and
related topics, especially at school
level, and to put the fun back into
learning computing."
Future Engineers/Programmers!
(flickr/lebeus)
03/12/2012
Tech Mesh London
Slide 26 of 45
34. GPIO Proxy
⢠Replaces â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.
03/12/2012
Tech Mesh London
Slide 34 of 45
35. Fine Grain Abstraction
⢠Advantages
â Application code becomes simpler
â Concise and shorter modules
â Testing becomes easier
â Code re-use (potentially) increases
⢠Disadvantage
â Architecting fine grain systems is difficult
03/12/2012
Tech Mesh London
Slide 35 of 45
43. Packages for Embedded Architectures
https://www.erlang-solutions.com/downloads/download-erlang-otp
03/12/2012
Tech Mesh London
Slide 43 of 45
44. Erlang Embedded Training Stack
⢠A complete package for people interested in
developing the next generation of concurrent
and distributed Embedded Systems
⢠Training Modules:
â Embedded Linux Primer
â Erlang/OTP 101
â Erlang Embedded Framework
Get in touch if youâre interested.
03/12/2012
Tech Mesh London
Slide 44 of 45
45. Thank you
⢠http://erlang-embedded.com
⢠embedded@erlang-solutions.com
⢠@ErlangEmbedded
â
The world is concurrent.
Things in the world don't share data.
Things communicate with messages.
Things fail.
- Joe Armstrong
Co-inventor of Erlang
03/12/2012
Tech Mesh London
Slide 45 of 45