Use Petri Nets to Improve your Concurrent Programming Course Jo~o Paulo Barros Escola Superior de Tecnologia e Gest~o de Beja Instituto Polit(~cnico de Beja Rua Afonso III, n. ° 1, 7800-050 Beja - Portugal j p b @ e s tig. ipbej a. pt Abstract Petri nets are recommended as a learning aid in a concurrent programming course covering modelling and verification techniques, based on state space analysis, and translation o f formal models to Java programs. The Application Introduction Our concurrent programming course is based on the book by Jeff Magee and Jeff Kramer [1], since 1999. The book clearly and efficiently presents modelling and verification techniques using a simple process algebra language, named FSP (Finite State Processes) and an associated tool (LTSA) delivered with the book. It then presents a simple but effective technique to translate models to concurrent programs in the Java Programming language. The L T S A tool allows the modelling o f systems in FSP. Starting from the model the tool is capable of graphically present the processes as state machines. It also generates the state machine resulting from the parallel composition o f processes. Then it is possible to verify progress and safety properties as well as executing the model through the use o f an interactive simulator where, in each execution step, the user selects one o f the enabled actions. We have found that the approach followed in the book, although quite effective, can be significantly improved by the simultaneous presentation and use o f Petri nets [2]. The Motivation The FSP language translates each process to a graphical representation o f a state machine. The user sees the final system as the result from the parallel composition o f those state machines. Each necessary synchronisation is specified through the use o f the same action (same name) in more than one state machine. The composed state machine, contains all the interleavings allowed by the synchronisations. This is very useful to understand the concept o f interleaving and, by consequence, the state explosion problem, but at the cost o f making unclear the dependencies between processes, namely their synchronisations. Even the parallelism is not clear as the interleaving hides it under the states representing combinations of more than one state in the original state machines. By contrast, a Petri net allows a clear visualization not only o f the initial state machines (which are just a particular case o f a Petri net) but also o f the parallel composition and respective synchronisations. This increased expressiveness o f Petri nets was the decisive reason to use them in the concurrent programming course. Petri nets are presented along the course, together with the c o r r e s p o n d i n g F S P c o n s t r u c t s . In this w a y , s t u d e n t s a r e a b l e to u n d e r s t a n d t h e s i m i l a r i t i e s o f b o t h n o t a t i o n s a n d a l s o t h e a d v a n t a g e s a n d d i k a d v a n t a g e s a s a p p l i e d to e a c h concept. Most notably students are forced to separate the concepts from their expression in one particular modelling tool. So that the overhead o f learning yet another notation is no obstacle to the intended course objectives, ordinary Petri nets were preferred against other Petri nets classes which although more powerful would require too much course time. Ordinary Petri nets also have the added and very significant advantage o f mapping very nicely to FSP models. That is demonstrated in the examples at http://www.estig.ipbeja.pt/-jpb/pn_concurrency.html. A simple and friendly Petri net tool was used: Visual Object Net++. This and many others can be found in the Petri nets tools database [3]. Students react very favourably to the use o f Petri net tools, namely the ones that allow the graphical editing and simulation (token-player) o f Petri net models. Each course section has the following structured sequence: (1)concepts, (2)relevant FSP constructs, (3)relevant Petri net constructs, (4)construction o f the FSP model and analysis o f its behaviour using the L T S A tool, (5)construction o f the Petri net model starting from the state machines generated by the L T S A tool, (6)simulation o f the Petri net model, (7)translation to a U M L class or object diagram, (8)development o f the Java program. Points 3, 5 and 6 constitute the proposed additions to the methodology in [1]. The Results W e have found the Petri net formalism to be particularly valuable in the understanding o f synchronization, deadlock, conflict and starvation. Students like the additional insight to the system behaviour that Petri nets offer, namely the explicit specification o f inter-process synchronization by means o f the Petri net transitions and, particularly, the visual simulation o f the parallel processes.
/lp/association-for-computing-machinery/use-petri-nets-to-improve-your-concurrent-programming-course-poster-i7mSQmeO01