SlideShare a Scribd company logo
1 of 17
PROGRAMMING MODELS FOR
EVENT CONTROLLED PROGRAMS
PRESENTED BY:
PRIYA KAUSHAL
ROLL NO. 152615
ECE (ME) REGULAR
PRESENTED TO:
Dr. KANIKA SHARMA
State machine model
State machine is a model in which it is assumed that there are states and state transition
functions, which produce the states.
A state transition function is a function, which changes a state to its next state.
PROCESS:- When there are inputs to a process that change the state of the process to a
new state, and generate outputs which may also be the inputs for the next state.
Example of Door
• opened
• closed
states
• close door
• Open door
State
transition
function
Examples of States
Washing Rinsing Drying
Process of washing machine: Idle
Receiving A Ring
Dialling
Connected
Exchanging Messages
A telephone process
Programming Model for an
Event Controlled or Response
Controlled Programs
A programming model is to assume that the running process (program flow) can be considered as
running of a machine in a particular state, which will lead to other states on an event(s) resulting into
state transition.
A program flow in system can be modelled simply by an inter-state transition (from one state to
another).
Steps in Modelling as State machine
Transition to a new state occurs from the previous state on an event (input). The event may be setting a value of certain
parameter or the result of the execution of certain codes. A transition may be also be interrupt flag driven.
A state is identified by a flag condition or set of codes being executed or set of values of certain parameters.
A state can receive multiple tokens (inputs, messages, flags interrupts) from another state (s). A token (event) means either
an input or event-input.
A state can generate multiple tokens (outputs, messages, flags interrupts).
Steps that model or represent the states and inter-state transitions :
1
2
3
4
Finite State Machine (FSM)
Model
In a finite states machine model, a process or function can be described by means of finite states.
There is only one directed incoming arc and one outgoing arc at a state.
A state from a process flow in FSM can lead to any one of the several possible subsequent states. This
will depend on the output function and state transition function at the state.
Example
3 Bit Counter
Count Signal For Increments
Reset to 0 when counter reaches its maximum
value
Modelling a process as Finite
State Machine (FSM)
• Finite set of inputs (tokens or event-flags or status flags) with their
values for reaching the state.
• Finite actions (for example computations) at the state.
• Finite set of outputs with their possible values and an output function
for the state that give the outputs.
• State transition function for each state to take it to the next state.
Followings
specified
for each
sate:
Timer Idle Timer
Start
Timer
Running
Load Input
Num-Ticks
Decrement Input
Event
Output
Count=Num-Ticks
Output
Count=Count-1
Output
Count=0
Timeout Flag=Set
Decrement
Input Event when Count=1
TimerIdle
Use of FSM Model
States of a timer using FSM
Example…..
Use of FSM Model
Idle
Start
Running
Finished
 ‘Idle’ State: it starts state transition on loading
an input, Num-Ticks (number of ticks after
which the timer finishes) and transition to ‘Start’
state occurs.
 ‘Running’ State: on each clock input for
decrement, the Count value decrements.
 ‘Finished’ State: program flows to finished state
when Count reaches to zero.
A timer has four finite states:
Use of FSM Model
Function Idle Function Call Function
Executing
Call Save Over
Output
Saves current status and values on
stack
End
Return
Instruction
Function Return
Output
Restores saved status and values from
stack
Example….
States of a call function using FSM
Use of FSM Model
Idle
Call
Executing
Return
 An ‘idle’ state to ‘call’ state transition takes place when a
function-call occurs in the program. Output from this state is
saved on to a stack.
 Instructions are executed in the ‘executing’ state and program
counter changes with the program flow.
 The transition to ‘return’ state happens when the instruction
reaches the return instruction.
 The transition to ‘idle’ state occurs after retrieving the saved
status and values from the stack.
A call function has four finite states:
FSM State Table
• When the FSM model is represented graphically with circles and directed arcs,
It becomes complex in the case of a complex process with a large number of states.
• To design software using the model, a state table can then be designed for representation of every
state in its rows.
Use of State Table for Real Time Programming
FSM State Table
1
• Present state name or identification.
2
• Action(s) at state until some event(s).
3
• The events that cause the execution of state transition function.
4
• Output(s) from the state output function(s).
5
• Next state.
6
• Expected time interval for finishing the transitions to new state after event.
Coding using each row
While (present state) { action ( ); if (event =……..; token =…….)
{output =………; StateTransitionFunction ( ); }; }
Or
Switch (state)
Case present state: action ( ); if (event=…….; token =……)
{output =……..; StateTransitionFunction ( ); }; }
Thank you

More Related Content

What's hot (20)

push down automata
push down automatapush down automata
push down automata
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Finite state automaton
Finite state automatonFinite state automaton
Finite state automaton
 
ENCAPSULATION AND TUNNELING
ENCAPSULATION AND TUNNELINGENCAPSULATION AND TUNNELING
ENCAPSULATION AND TUNNELING
 
02 protocol architecture
02 protocol architecture02 protocol architecture
02 protocol architecture
 
Interfacing With High Level Programming Language
Interfacing With High Level Programming Language Interfacing With High Level Programming Language
Interfacing With High Level Programming Language
 
Ch1
Ch1Ch1
Ch1
 
Moore and mealy machine
Moore and mealy machineMoore and mealy machine
Moore and mealy machine
 
Gsm radio-interface
Gsm radio-interfaceGsm radio-interface
Gsm radio-interface
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Mac protocols
Mac protocolsMac protocols
Mac protocols
 
Gsm architecture
Gsm architectureGsm architecture
Gsm architecture
 
HiperLAN.ppt
HiperLAN.pptHiperLAN.ppt
HiperLAN.ppt
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
 
Application Layer
Application Layer Application Layer
Application Layer
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
 
Gigabit Ethernet
Gigabit EthernetGigabit Ethernet
Gigabit Ethernet
 
Context model
Context modelContext model
Context model
 
Lecture 6 -_presentation_layer
Lecture 6 -_presentation_layerLecture 6 -_presentation_layer
Lecture 6 -_presentation_layer
 

Similar to Programming models for event controlled programs

States, state graphs and transition testing
States, state graphs and transition testingStates, state graphs and transition testing
States, state graphs and transition testingABHISHEK KUMAR
 
States, state graphs and transition testing
States, state graphs and transition testingStates, state graphs and transition testing
States, state graphs and transition testinggeethawilliam
 
Unit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programmingUnit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programmingLeahRachael
 
Sessionizing Uber Trips in Realtime - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime  - Flink Forward '18, BerlinSessionizing Uber Trips in Realtime  - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime - Flink Forward '18, BerlinAmey Chaugule
 
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...Flink Forward
 
Real World State And Notification Broker
Real World State And Notification BrokerReal World State And Notification Broker
Real World State And Notification BrokerXeDotNet
 
[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in CapellaObeo
 
Model Execution and System Simulation
Model Execution and System SimulationModel Execution and System Simulation
Model Execution and System SimulationObeo
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
state_machines1.pdf
state_machines1.pdfstate_machines1.pdf
state_machines1.pdfrdjo
 
Software System Engineering - Chapter 14
Software System Engineering - Chapter 14Software System Engineering - Chapter 14
Software System Engineering - Chapter 14Fadhil Ismail
 
Define synchronous system.What is a dynamic indicator on a l.pdf
Define synchronous system.What is a dynamic indicator on a l.pdfDefine synchronous system.What is a dynamic indicator on a l.pdf
Define synchronous system.What is a dynamic indicator on a l.pdfalshaikhkhanzariarts
 
STATE DIAGRAM.pptx
STATE DIAGRAM.pptxSTATE DIAGRAM.pptx
STATE DIAGRAM.pptxssuser2d043c
 
Automata based programming
Automata based programmingAutomata based programming
Automata based programmingVisnuDharsini
 
State space analysis.pptx
State space analysis.pptxState space analysis.pptx
State space analysis.pptxRaviMuthamala1
 
State Machine Diagram
State Machine DiagramState Machine Diagram
State Machine DiagramNiloy Rocker
 
State transition testing-software_testing
State transition testing-software_testingState transition testing-software_testing
State transition testing-software_testingMidhun S
 
20031109 WRUG Presentation
20031109 WRUG Presentation20031109 WRUG Presentation
20031109 WRUG PresentationManuel Sardinha
 

Similar to Programming models for event controlled programs (20)

States, state graphs and transition testing
States, state graphs and transition testingStates, state graphs and transition testing
States, state graphs and transition testing
 
States, state graphs and transition testing
States, state graphs and transition testingStates, state graphs and transition testing
States, state graphs and transition testing
 
Unit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programmingUnit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programming
 
Sessionizing Uber Trips in Realtime - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime  - Flink Forward '18, BerlinSessionizing Uber Trips in Realtime  - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime - Flink Forward '18, Berlin
 
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
 
Real World State And Notification Broker
Real World State And Notification BrokerReal World State And Notification Broker
Real World State And Notification Broker
 
Seminar State Chart1
Seminar State Chart1Seminar State Chart1
Seminar State Chart1
 
[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella
 
Model Execution and System Simulation
Model Execution and System SimulationModel Execution and System Simulation
Model Execution and System Simulation
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
 
state_machines1.pdf
state_machines1.pdfstate_machines1.pdf
state_machines1.pdf
 
Software System Engineering - Chapter 14
Software System Engineering - Chapter 14Software System Engineering - Chapter 14
Software System Engineering - Chapter 14
 
Define synchronous system.What is a dynamic indicator on a l.pdf
Define synchronous system.What is a dynamic indicator on a l.pdfDefine synchronous system.What is a dynamic indicator on a l.pdf
Define synchronous system.What is a dynamic indicator on a l.pdf
 
STATE DIAGRAM.pptx
STATE DIAGRAM.pptxSTATE DIAGRAM.pptx
STATE DIAGRAM.pptx
 
Automata based programming
Automata based programmingAutomata based programming
Automata based programming
 
State space analysis.pptx
State space analysis.pptxState space analysis.pptx
State space analysis.pptx
 
State Machine Diagram
State Machine DiagramState Machine Diagram
State Machine Diagram
 
State transition testing-software_testing
State transition testing-software_testingState transition testing-software_testing
State transition testing-software_testing
 
20031109 WRUG Presentation
20031109 WRUG Presentation20031109 WRUG Presentation
20031109 WRUG Presentation
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Programming models for event controlled programs

  • 1. PROGRAMMING MODELS FOR EVENT CONTROLLED PROGRAMS PRESENTED BY: PRIYA KAUSHAL ROLL NO. 152615 ECE (ME) REGULAR PRESENTED TO: Dr. KANIKA SHARMA
  • 2. State machine model State machine is a model in which it is assumed that there are states and state transition functions, which produce the states. A state transition function is a function, which changes a state to its next state. PROCESS:- When there are inputs to a process that change the state of the process to a new state, and generate outputs which may also be the inputs for the next state.
  • 3. Example of Door • opened • closed states • close door • Open door State transition function
  • 4. Examples of States Washing Rinsing Drying Process of washing machine: Idle Receiving A Ring Dialling Connected Exchanging Messages A telephone process
  • 5. Programming Model for an Event Controlled or Response Controlled Programs A programming model is to assume that the running process (program flow) can be considered as running of a machine in a particular state, which will lead to other states on an event(s) resulting into state transition. A program flow in system can be modelled simply by an inter-state transition (from one state to another).
  • 6. Steps in Modelling as State machine Transition to a new state occurs from the previous state on an event (input). The event may be setting a value of certain parameter or the result of the execution of certain codes. A transition may be also be interrupt flag driven. A state is identified by a flag condition or set of codes being executed or set of values of certain parameters. A state can receive multiple tokens (inputs, messages, flags interrupts) from another state (s). A token (event) means either an input or event-input. A state can generate multiple tokens (outputs, messages, flags interrupts). Steps that model or represent the states and inter-state transitions : 1 2 3 4
  • 7. Finite State Machine (FSM) Model In a finite states machine model, a process or function can be described by means of finite states. There is only one directed incoming arc and one outgoing arc at a state. A state from a process flow in FSM can lead to any one of the several possible subsequent states. This will depend on the output function and state transition function at the state.
  • 8. Example 3 Bit Counter Count Signal For Increments Reset to 0 when counter reaches its maximum value
  • 9. Modelling a process as Finite State Machine (FSM) • Finite set of inputs (tokens or event-flags or status flags) with their values for reaching the state. • Finite actions (for example computations) at the state. • Finite set of outputs with their possible values and an output function for the state that give the outputs. • State transition function for each state to take it to the next state. Followings specified for each sate:
  • 10. Timer Idle Timer Start Timer Running Load Input Num-Ticks Decrement Input Event Output Count=Num-Ticks Output Count=Count-1 Output Count=0 Timeout Flag=Set Decrement Input Event when Count=1 TimerIdle Use of FSM Model States of a timer using FSM Example…..
  • 11. Use of FSM Model Idle Start Running Finished  ‘Idle’ State: it starts state transition on loading an input, Num-Ticks (number of ticks after which the timer finishes) and transition to ‘Start’ state occurs.  ‘Running’ State: on each clock input for decrement, the Count value decrements.  ‘Finished’ State: program flows to finished state when Count reaches to zero. A timer has four finite states:
  • 12. Use of FSM Model Function Idle Function Call Function Executing Call Save Over Output Saves current status and values on stack End Return Instruction Function Return Output Restores saved status and values from stack Example…. States of a call function using FSM
  • 13. Use of FSM Model Idle Call Executing Return  An ‘idle’ state to ‘call’ state transition takes place when a function-call occurs in the program. Output from this state is saved on to a stack.  Instructions are executed in the ‘executing’ state and program counter changes with the program flow.  The transition to ‘return’ state happens when the instruction reaches the return instruction.  The transition to ‘idle’ state occurs after retrieving the saved status and values from the stack. A call function has four finite states:
  • 14. FSM State Table • When the FSM model is represented graphically with circles and directed arcs, It becomes complex in the case of a complex process with a large number of states. • To design software using the model, a state table can then be designed for representation of every state in its rows. Use of State Table for Real Time Programming
  • 15. FSM State Table 1 • Present state name or identification. 2 • Action(s) at state until some event(s). 3 • The events that cause the execution of state transition function. 4 • Output(s) from the state output function(s). 5 • Next state. 6 • Expected time interval for finishing the transitions to new state after event.
  • 16. Coding using each row While (present state) { action ( ); if (event =……..; token =…….) {output =………; StateTransitionFunction ( ); }; } Or Switch (state) Case present state: action ( ); if (event=…….; token =……) {output =……..; StateTransitionFunction ( ); }; }