Presentation is loading. Please wait.

Presentation is loading. Please wait.

CY2003 Computer Systems Lecture 7 Petri net. © LJMU, 2004CY2003- Week 72 Overview Petri net –concepts –Petri net representation –Firing a transition –Marks.

Similar presentations


Presentation on theme: "CY2003 Computer Systems Lecture 7 Petri net. © LJMU, 2004CY2003- Week 72 Overview Petri net –concepts –Petri net representation –Firing a transition –Marks."— Presentation transcript:

1 CY2003 Computer Systems Lecture 7 Petri net

2 © LJMU, 2004CY2003- Week 72 Overview Petri net –concepts –Petri net representation –Firing a transition –Marks (Tokens) Modeling with Petri net –Events and condition Mutual exclusion

3 Petri Net: Background

4 © LJMU, 2004CY2003- Week 74 Background A petri net was introduced by a German mathematician and used to model a system –Condition: a Boolean description of the state of the system –Event: an action that depends on the state of the system Petri net is a graphical and mathematical tools for the analysis of discrete event dynamic systems. –The system model is represented by a set of conditions and a set of events –A condition is represented by a place and an event by transition.

5 © LJMU, 2004CY2003- Week 75 Petri net representation In the graphical representation for a of petri net: –a place is drawn as a circle –a transition is drawn as a bar.

6 © LJMU, 2004CY2003- Week 76 Marks (Tokens) A marking M is an assignment of tokens (dots) to places of a petri net. Dots are placed in the circle to represent place in which its condition is satisfied –e.g. a resource is available or operation in a process The marking can be represented as M = (1,1,0)

7 © LJMU, 2004CY2003- Week 77 Marks (Tokens) A place can have more than one token and therefore can represent a queue –(e.g. a buffer holding several processes).

8 © LJMU, 2004CY2003- Week 78 Firing a transition Executing a marked Petri net causes the number and positions of the token to change. The rules for the execution are: –A transition is enabled if all its input places contain at least one token. –Any enabled transition may fire –Firing of a transition results in one token being removed from each of its input places and being deposited of its output places –Execution halts when there are no enabled transitions. –Each time a transitions fires, the marking of the petri net will change.

9 © LJMU, 2004CY2003- Week 79 Example

10 © LJMU, 2004CY2003- Week 710 Modelling with petri net Petri net is mainly used for modelling. –Many systems can be modelled by petri net. The system may be of many different kinds like computer hardware, computer software, physical system and so on. –Petri net is used to model the occurrence of various events and activities in the system.

11 © LJMU, 2004CY2003- Week 711 Concurrency and Synchronisation Concurrency means that two events could take place in parallel, without interfering with one another. –By having two places as input conditions to the same transition, these two conditions become synchronised.

12 © LJMU, 2004CY2003- Week 712 Conflict Two transitions t 1 and t 2 are said to be conflict if either t 1 or t 2 can occur but not both of them, –i.e., when there is one place that is acting as input condition to a number of transitions. –Therefore, only one transition can be fire.

13 Mutual exclusion

14 © LJMU, 2004CY2003- Week 714 Recall Mutual exclusion is a technique of defining entry and exit code so that at most one process is allowed to access the critical region at the same time. –The idea is that no process is allowed to enter the critical region, unless it checks that no other process is executing its own critical region. Mutual exclusion can be represented in Petri net using conflict.

15 © LJMU, 2004CY2003- Week 715 Mutual exclusion The place s represents the permission to enter the critical region and there must be token in p 1 and p 2. –If both processes want to enter the critical region simultaneously, then transition t 1 and t 2 are in conflict –i.e., only one of them can fire.

16 © LJMU, 2004CY2003- Week 716 Producer consumer problem bounded buffer

17 © LJMU, 2004CY2003- Week 717 Analysis of Petri net Petri nets are capable of modelling a large variety of systems and properly representing the interactions between the various actions which can occur. –The strength of Petri net is its capability to model the system. However, modelling by itself is of little use and its necessary to analyse the modelled system. This could lead to important insights into the behaviour of the modelled system.

18 © LJMU, 2004CY2003- Week 718 Reachibility Given a Petri net, one would like to know which marking M r can be reached from an initial marking M 0. Example: For the Petri net of the bounded buffer consumer producer problem, M 0 = (1, 0, 1, 0, 0, n) and M 1 = (0, 1, 1, 0, 0, n) –is immediately reachable from the marking of M 0.

19 © LJMU, 2004CY2003- Week 719 Safeness A place in a Petri net is save if the number of tokens in that place never exceeds one. – A petri net is same if all its places are safe. what does this Petri net do? Is it safe?

20 © LJMU, 2004CY2003- Week 720 Boundedness A place is k-safe or k-bounded if the number of tokens in that place cannot exceed an integer k. –Therefore a place is 1-bounded is simply a safe place. Example: –The Petri net for the producer/consumer problem with a bounded buffer, is it safe? Bounded? –The Petri net for the producer/consumer problem with a unbounded buffer, is it bounded? Why?

21 © LJMU, 2004CY2003- Week 721 Conservation A Petri net with an initial marking M 0, is strictly conservative, –if for all the reachable marking, the total number of tokens in each marking is exactly the same as the initial marking. A Petri net can be used to model resource allocation systems. In this systems some tokens may represents the resources. –Therefore, in such Petri nets conservation is an important property such that resources can neither be created nor destroyed.

22 © LJMU, 2004CY2003- Week 722 Liveness Another problem that could occur in resource allocation is deadlock. –A deadlock in a Petri net is a transition (or a set of transition) which cannot fire. –A transition is alive if it is not deadlock. –A transition is live in a marking M if it is potentially fireable in every marking in the Petri net.

23 © LJMU, 2004CY2003- Week 723 Exercises For the following Petri net, indicate whether each is bounded, live, and conservative or not and show why?

24 © LJMU, 2004CY2003- Week 724 Summary Petri net –concepts –Petri net representation –Firing a transition –Marks (Tokens) Modeling with Petri net –Events and condition Mutual exclusion


Download ppt "CY2003 Computer Systems Lecture 7 Petri net. © LJMU, 2004CY2003- Week 72 Overview Petri net –concepts –Petri net representation –Firing a transition –Marks."

Similar presentations


Ads by Google