Narayan Kumar Trainee Software Consultant Knoldus Software LLP Role of FSM In Akka
Narayan KumarTrainee Software Consultant
Knoldus Software LLP
Role of FSM In Akka
AgendaAgenda● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
AgendaAgenda● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
● Finite-state machine (FSM), also called a state machine, is a common, language-independent modeling technique.
● An FSM is called a machine because it can only be in one of a finite number of states.
● Finite-state machine (FSM), also called a state machine, is a common, language-independent modeling technique.
● An FSM is called a machine because it can only be in one of a finite number of states.
What is FSM ? What is FSM ?
AgendaAgenda● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
Why do we need FSM ? Why do we need FSM ?
● Simulations
● Automata based programming
● Model and Execute Rules
● Simulations
● Automata based programming
● Model and Execute Rules
AgendaAgenda● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
Components of FSM Components of FSM
● State
● Data
● Messages to the actor is analogous to Events
● Transitions
● Timers
● State
● Data
● Messages to the actor is analogous to Events
● Transitions
● Timers
Example of FSM State Example of FSM State
/** * Some fsm philosopher states */sealed trait FSMPhilosopherStatecase object Waiting extends FSMPhilosopherStatecase object Thinking extends FSMPhilosopherStatecase object Hungry extends FSMPhilosopherStatecase object WaitForOtherChopstick extends FSMPhilosopherStatecase object FirstChopstickDenied extends FSMPhilosopherStatecase object Eating extends FSMPhilosopherState
** Some messages for the chopstick*/sealed trait ChopstickMessageobject Take extends ChopstickMessageobject Put extends ChopstickMessagefinal case class Taken(chopstick: ActorRef) extends ChopstickMessagefinal case class Busy(chopstick: ActorRef) extends ChopstickMessage
Example of FSM EventsExample of FSM Events
AgendaAgenda● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
Features of FSMFeatures of FSM
● FSM give us the ability to describe complex behavior in a clear, concise manner.
● We can design dynamic behavior, depending on the actor's state of business model.
● FSM give us the ability to describe complex behavior in a clear, concise manner.
● We can design dynamic behavior, depending on the actor's state of business model.
AgendaAgenda● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
● What is FSM?
● Why do we need FSM?
● Components of FSM
● Features of FSM
● About Dining Philosophers problem
● Code Review & Demo
About Dining Philosophers problemAbout Dining Philosophers problem
● The dining-philosophers problem is considered a classic synchronization problem.● It is a simple representation of the need to allocate several resources among several processes in a deadlock and starvation free manner.
● The dining-philosophers problem is considered a classic synchronization problem.● It is a simple representation of the need to allocate several resources among several processes in a deadlock and starvation free manner.
Code Review & DemoCode Review & Demo
Thank youThank you