Top Banner
Narayan Kumar Trainee Software Consultant Knoldus Software LLP Role of FSM In Akka
16
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: Fsm knolx

Narayan KumarTrainee Software Consultant

Knoldus Software LLP

Role of FSM In Akka

Page 2: Fsm knolx

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

Page 3: Fsm knolx

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

Page 4: Fsm knolx

● 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 ?

Page 5: Fsm knolx

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

Page 6: Fsm knolx

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

Page 7: Fsm knolx

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

Page 8: Fsm knolx

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

Page 9: Fsm knolx

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

Page 10: Fsm knolx

** 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

Page 11: Fsm knolx

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

Page 12: Fsm knolx

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.

Page 13: Fsm knolx

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

Page 14: Fsm knolx

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.

Page 15: Fsm knolx

Code Review & DemoCode Review & Demo

Page 16: Fsm knolx

Thank youThank you