Study of Erlang for Building Real-Time SystemsByDinesh RajpootRoll no. 09305043Under the guidance of Prof. Kavi AryaAugust  20, 2010
OutlineIntroduction to Erlang
Erlang Highlights
Declarative
Concurrency
Fault-tolerant
Hot Code Swapping
Multi Core Programming Applications of ErlangRobot Programming in Erlang
Challenges and Solutions
Case Study(Adaptive Cruise Control)
Conclusion and Future Work
ReferencesIntroduction to ErlangErlang 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;}
DeclarativeConcentrate 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.
ConcurrencyEach 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.
ConcurrencyCreate  a  processPid = spawn(Module, fun, [Arguments])Send and receivePid ! message      receive            message1  -> actions1;		message2 -> actions2;		……		after   Time -> time out actions;	 end.
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}shellPid{<0.2.0>, hello}stop<0.1.0><0.2.0>
1,000erlangjavaC#100Microseconds/process101101001,00010,000100,000Number of processesProcess creation times (LOG/LOG scale)> 200,000processesSource:Joe ArmstrongSICS
100,000erlangjava10,000C#1,000Microseconds/message1001011101001,00010,000100,000Number of processesMessage passing times (LOG/LOG scale)> 200,000processesSource:Joe ArmstrongSICS
Fault TolerantErlang provides fault tolerance through isolating errors and ensuring nonstop operation.            {‘EXIT’, Pid, Reason}                                                        {‘EXIT’, Pid, Reason}                   {‘EXIT’, Pid, Reason}
Hot Code SwappingEmbedded  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.

Erlang real time