FSM, Petri nets and State charts - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

FSM, Petri nets and State charts

Description:

... of the windshield wipers of a car is determined by a stick with positions: ... Dining Philosophers. We have 5 philosophers sitting around a round table. ... – PowerPoint PPT presentation

Number of Views:380
Avg rating:3.0/5.0
Slides: 29
Provided by: ila2
Category:
Tags: fsm | charts | nets | petri | state

less

Transcript and Presenter's Notes

Title: FSM, Petri nets and State charts


1
FSM, Petri nets and State charts
2
Final State machine
  • FSM - Final state machine (S, I, f)
  • S The states of the system
  • I The set of transitions from one state to
    another
  • F SI -gt S, describes the legal transitions in
    the system
  • Simple, but has limited computational power
  • FSM has no memory
  • Using states as memory is inefficient
  • State space explosion for large problems

3
Reader-Writer
write
consume
P1
P2
C1
C2
produce
read
read
read
0
1
2
write
write
2 slot buffer
4
write
write
lt1,p1,c1gt
lt2,p1,c1gt
lt0,p1,c1gt
consume
consume
consume
produce
produce
produce
read
read
lt2,p1,c2gt
lt0,p1,c2gt
lt1,p1,c2gt
produce
produce
produce
read
read
consume
write
write
consume
lt0,p2,c2gt
lt1,p2,c2gt
lt2,p2,c2gt
5
FSM questions
  • Using FSMs, describe a lighting system consisting
    of one lamp and two buttons. If the lamp is off,
    pushing either button causes the lamp to switch
    on and conversely
  • Describe a system with two lamps and one button.
    When the light is off, pushing the button causes
    the first light to go on. Pushing the button
    again causes the second lamp to go on and the
    first to go off. Pushing the button again causes
    both lamps to go on, and pushing it once more
    causes both lamps to go off
  • Describe a system that accepts an identifier that
    consists of letters and digits and begins with a
    letter

6
Control of Chemical Plant
  • Describe a simple control of a chemical plant
    where temperature and pressure must be monitored
    for safety reasons. When either reaches a
    critical level the plant should turn off. The
    system restarts when the cause of the failure is
    fixed
  • Enhance the previous scheme. When one of the
    conditions occur, a recovery action is
    automatically invoked . If, after a while, the
    recovery action succeeds the system resets to
    normal state. Otherwise the system must turned
    off. If the system tries to overcome one kind of
    anomaly and the second one occurs the system must
    be turned off

7
State Transition Diagram - Definitions
  • A state is a condition in which the thing being
    modeled stays for some period of time, during
    which it behaves in the same way
  • A transition is a change of state, usually caused
    by some particular event
  • An event is something which happens outside the
    thing which is being considered, possibly
    requiring some action to be taken. Events may be
    caused by the arrival of some data, or some
    simple stimulus. Some events may convey data as
    input

8
State Transition Diagram - Definitions
  • A guard on a transition is some condition which
    must be be true for the event to cause a
    transition
  • Actions are what is done by the thing being
    modeled in response to an event
  • An activity is something which is done by the
    thing being modeled, while it is in a particular
    state
  • General form of a transition
  • event(list of input data) guard / action

9
Transitions
10
Digital watch
  • Two buttons ModeButton and IncButton. Pressing
    either of these generates an event that may cause
    a transition
  • Three states Display, SetHours, SetMinutes
  • Display is the start state. Event ModeButton
    causes a transition from Display to SetHours,
    from SetHours to SetMinutes and from SetMinutes
    to Display
  • Event IncButton causes the action Increase
    Hours or Increase Minutes (depends on the
    state)
  • How can we add an activity?

11
Window Shield wiper
  • The operation of the windshield wipers of a car
    is determined by a stick with positions OFF
    (speed 0), INT, LOW  (speed 20) and HIGH (speed
    40). At the end of the stick a button determines
    the speed when INT 1 (speed 2), 2 (speed 4), 3
    (speed 6)
  • Draw a state transition diagram and a state chart
    diagram describing the system
  • Add activities and actions

12
Petri nets definition
  • PN ( S, T, F, MI )
  • PN describe the state of the system. Transitions
    describe actions or events and the presence of a
    token in a place denotes existence of some
    condition or state

13
(No Transcript)
14
How to avoid starvation
15
Deadlock situation
P1
P2
.
.
t2
t1
P3
P4
P5
..
t3
t4
P6
P7
t3
t4
P8
P9
2
2
t5
t6
16
Warehouse Automation Example
  • Specifies requirements of a system
  • P1 gt a truck arrives at the loading dock
  • P2 gt paperwork is processed and inventory
    checked
  • P3 gt conveyor belts move from the loading dock
    to the warehouse (transporting people, robots,
    forklifts, etc)

. .
P1
T1
P2
P3
P4
P5
T2
T3
T4
T5
17
  • P4 gt conveyor belt move back from warehouse to
    loading dock with merchandise.
  • P5 gt goods loaded into the truck
  • Concurrent handling of multiple trucks can be
    modeled by multiple tokens
  • But a token is present in P3, then another token
    cannot be present in P4 (the conveyor belts
    cannot move in two opposite direction at the same
    time)
  • Therefore, the above model can be modified as
    follows to specify the above requirements of the
    system.

.
. .
P1
T1
P2
P3
P4
P5
T2
T3
T4
T5
  • Now a token can enter P3 only if there is no
    token in P4

18
  • Similarly to specify the requirements that only
    paperwork of one truck can be processed at a time
    and merchandise of only one truck can be loading
    into the truck at a time, the above model can be
    modified as follows

.
. .
P1
T1
P2
P3
P4
P5
T2
T3
T4
T5
.
.
19
PN - Questions
  • Using PNs, describe a lighting system consisting
    of one lamp and two buttons. If the lamp is off,
    pushing either button causes the lamp to switch
    on and conversely
  • Describe a system with two lamps and one button.
    When the light is off, pushing the button causes
    the first light to go on. Pushing the button
    again causes the second lamp to go on and the
    first to go off. Pushing the button again causes
    both lamps to go on, and pushing it once more
    causes both lamps to go off

20
Dining Philosophers
  • We have 5 philosophers sitting around a round
    table. Each philosopher can eat or think. In
    order to eat a philosopher has a spaghetti plate
    and he needs to use two forks, which lie to his
    right and his left
  • Two close philosophers cant eat at the same time
  • Describe a PN that describes the above problem,
    which avoids deadlocks
  • Describe a PN that describes the above problem,
    which allows deadlocks

21
PN Extensions 1
  • A priority function pri from transitions to
    natural numbers, pri T ? N
  • When several transitions are enabled, only the
    ones with maximum priority are allowed to fire
  • Among those transitions that are allowed to fire
    at the same time, the one to fire is chosen
    non-deterministically

22
PN Extensions 2
  • A pair of constants lttmin, tmaxgt is associated
    with each transition
  • Once a transition is enabled, it must wait for at
    least tmin to elapse before it can fire
  • If enabled, it must fire before tmax has elapsed,
    unless it is disabled by the firing of another
    transition before tmax

23

P

P

1


4

P
P


2

3
T1



T3
T2




tmin 0
tmin 1
tmin 2



tmax 5
tmax 4
tmax 3



1


priority

2
priority
priority
3
  • At t0, i.e, when the above system begins to
    execute, all the transitions above are enabled.
    However, only T3 can fire at t0. At t1,
    transition T1 is also ready to fire. If T3 has
    not fired before t1, then T1 cannot fire until
    T3 has fired, since T3 has higher priority than
    T1. If T3 does not fire till t4, then T1 can
    never fire since T1 must fire before t4

24




P
P
P




4
1
P
3

2

T1

T2
T3





tmin 0
tmin 1
tmin 2



tmax 5
tmax 4
tmax 3



1


priority

2
priority
priority
3
If T3 fires before t1, T1 can fire at t1 or
anytime after t1 but before t2. This is because
at t2, T2 can fire and T2 has higher priority
than T1, therefore it will prevent T1 from
firing. If T1 fires before t2, then T2 gets
disabled and can never fire.
25




P
P
P




4
1
P
3

2

T1

T2
T3





tmin 0
tmin 1
tmin 2



tmax 5
tmax 4
tmax 3



1


priority

2
priority
priority
3
If T2 fires before T1 fires, it disables T1.
Therefore, T1 can never fire after T2 fires. If
T3 does not fire before t2, then it cannot fire
till t3 since T2 can fire at t2 and T2 has
higher priority than T3. If T2 fires before t3,
then T1 is disabled, but now T3 can fire anytime
before t5. After t3, if T3 has not fired yet,
it can fire anytime before t5 irrespective of
whether T2 has fired or not.
26
PN Extensions 3
  • Tokens modified to carry a value
  • Transitions are modified to have associated
    predicates and functions
  • A transition with k input places and h output
    places is enabled if there exists a k-tuple of
    tokens, such that the predicate associated with
    the transition is satisfied by the values of the
    tokens
  • The production of one token for each output place
    is determined by a function

27
PN extensions - Questions
  • Describe a message dispatcher
  • The dispatcher receives messages from two
    different input-channels. it checks the parity of
    each message. If the parity is wrong, it sends a
    "nack" through a reply-channel (there is one such
    reply-channel for each input channel)
  • If the parity is right, it places the message in
    a buffer. The buffer may store ten messages. When
    the buffer is full, the dispatcher sends the
    whole contents of the buffer to a processing unit
    through another channel. No message can be placed
    in a full buffer

28
PN extensions - Questions
  • Add suitable priorities to the previous Petri
    Net. If the dispatcher is in a condition where it
    can either receive a message from an
    input-channel or forward the buffer contents to
    the processor, then it must order its priorities
    as follows First get message then forward the
    buffer contents
Write a Comment
User Comments (0)
About PowerShow.com