Erlang real time

  • 3,162 views
Uploaded on

ERLANG

ERLANG

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,162
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
6

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Study of Erlang for Building Real-Time Systems
    By
    Dinesh Rajpoot
    Roll no. 09305043
    Under the guidance of
    Prof. Kavi Arya
    August 20, 2010
  • 2. Outline
    • Introduction to Erlang
    • 3. Erlang Highlights
    • 4. Declarative
    • 5. Concurrency
    • 6. Fault-tolerant
    • 7. Hot Code Swapping
    • 8. Multi Core Programming
    Applications of Erlang
    • Robot Programming in Erlang
    • 9. Challenges and Solutions
    • 10. Case Study(Adaptive Cruise Control)
    • 11. Conclusion and Future Work
    • 12. References
  • Introduction to Erlang
    Erlang was designed by Ericcson.
    It is a functional programming language.
    Variables are immutable.
    No side- effect(pure functions)
    Referential Transparency
    Int G =1; G is globalintplusG(int x){  return x + G;}
    intplusOne(int x){  return x+1;}
  • 13. Declarative
    Concentrate on “What” rather than “How”.
    The programs are concise.
    qsort([]) -> [];
    qsort([Pivot|T]) -> qsort([X || X <- T, X =< Pivot]) ++ [Pivot] ++
    qsort([X || X <- T, X > Pivot]).
    Programs are readable and easy to maintain.
    It increases productivity.
  • 14. Concurrency
    Each concurrent activity is called “process”.
    Processes don’t share data.
    Processes belong to language not operating system.
    Processes communicate through “message passing”not shared memory.
    Less process creation and message passing time.
  • 15. Concurrency
    Create a process
    Pid = spawn(Module, fun, [Arguments])
    Send and receive
    Pid ! message
    receive
    message1 -> actions1;
    message2 -> actions2;
    ……
    after Time -> time out actions;
    end.
  • 16. An example
    -module(echo).
    -export([start/0, loop/o]).
    start() ->
    Pid = spawn (echo, loop, [ ] ),
    Pid ! { self (), hello},
    receive
    { Pid, Msg } ->
    io:format ( “~w~n”, [Msg])
    end,
    Pid ! stop.
    loop() ->
    receive
    { From, Msg } ->
    From ! { self(), Msg},
    loop();
    stop -> true
    end.
    {<0.1.0>, hello}
    {<0.1.0>, hello}
    shell
    Pid
    {<0.2.0>, hello}
    stop
    <0.1.0>
    <0.2.0>
  • 17. 1,000
    erlang
    java
    C#
    100
    Microseconds/process
    10
    1
    10
    100
    1,000
    10,000
    100,000
    Number of processes
    Process creation times (LOG/LOG scale)
    > 200,000processes
    Source:
    Joe Armstrong
    SICS
  • 18. 100,000
    erlang
    java
    10,000
    C#
    1,000
    Microseconds/message
    100
    10
    1
    1
    10
    100
    1,000
    10,000
    100,000
    Number of processes
    Message passing times (LOG/LOG scale)
    > 200,000processes
    Source:
    Joe Armstrong
    SICS
  • 19. Fault Tolerant
    • Erlang provides fault tolerance through isolating errors and ensuring nonstop operation.
    {‘EXIT’, Pid, Reason} {‘EXIT’, Pid, Reason}
    {‘EXIT’, Pid, Reason}
  • 20. Hot Code Swapping
    Embedded systems are reactive.
    How can I update my system without shutting down?
    In Erlang , we can change code on-the-fly.
    We can keep 2 version of same module running.
  • 21. Multi-core Programming
    How to achieve?
    Use lots of processes.
    Avoid side effects.
    Avoid sequential bottleneck.
    Write “small message, big computation”.
    What is special about Erlang?
    Message passing system.
    No mutable data structure = No lock.
    No mutable data structure = Easy to parallelize.
  • 22. Applications of Erlang
    Erlang is useful when applications are concurrent, distributed and soft-real time.
    It is used in telecommunication systems from Ericsson.
    Some other commercial applications are:
    Facebook uses Erlang to power the backend of its chat service, handling more than 100 million active users.
    Mobile arts (GSM and UMTS services)
    T-Mobile uses Erlang in its SMS and authentication systems.
  • 23. Robot Programming in Erlang
  • 24. Challenges & Solutions
    Challenges
    Erlang can’t directly interact with hardware.
    Erlang can’t be converted into it’s equivalent C code.
    Communication latency between PC and Firebird-V.
    Solutions
    Use C as middle-layer between Erlang and Micro-controller.
    Use PC as master and Firebird as slave mode.
    We can use small, low cost, fan-less processor and run Erlang on it.
  • 25. Case Study
    Adaptive Cruise Control
    Robot will follow white line while maintaining safe distance from other robots.
    Robot using
    FireBird V (8051 micro-controller)
    Sensors using
    Whiteline sensors(Left, Middle, Right)
    Front sharp sensor
  • 26. Communication Model
    Erlang
    PC Micro-controller
    read_sensor
    Sensing
    value
    C program
    Actuating
    Take corrective measure
  • 27. Conclusion & Future Work
    Programs in functional languages are concise and readable.
    Concurrency model of Erlang helps in making concurrent programs without worrying about deadlocks.
    We have seen the possibility of implementing robotic system using Erlang.
    Since concurrency is crucial in building autonomous robotics applications, Erlang can be used in building such applications.
  • 28. References
    Joe Armstrong “Programming Erlang”, May 2007
    John Hughes "Why Functional programming Matters", 1984, revised in 1989 and 1990.
    Francesco Cesarini and Simon Thompson, "Erlang Programming, O'Reilly, June 2009 .
    Philip wadler "Functional Programming in the Real World“ http://homepages.inf.ed.ac.uk/wadler/realworld/ .
    Video lectures by Erlang- Training Consultancy
  • 29. Thank You