<< Chapter < Page Chapter >> Page >

We will model concurrency in two ways. First, we will use Promela, a language with C-like syntax.It is not a fully featured programming language, and is not intended for general computation. Instead, Promela(PROcess MEta-LAnguage) programs are intended to be simplifications or models of real-world systems, for use inverification. SPIN (Simple Promela INterpreter) is the tool for executing and verifying programs written in Promela.Second, we will use a simple state-based transition system that will help in understanding the specification and verification of Promelaprograms.

Here, we introduce Promela, SPIN, and the state-based transition system through a series of examples.For the moment, we will use SPIN merely as an interpreter, to run of Promela programs.In the next section , we will introduce the verification featuresof SPIN. ( Reference manuals and download/install instructions are available via the SPIN homepage, spinroot.com .)

Promela and spin basics

We start with a series of examples illustrating race conditions.

A tiny first program

1 /* A variable shared between all processes. */ 2 show int bal = 0;3 4 active proctype deposit()5 { 6 bal++;7 } 89 active proctype withdraw() 10 {11 bal--; 12 }

We have two threads, one running deposit and one running withdraw . The proctype keyword specifies that the following is code for a thread/process, while the active keyword specifies that the thread is started immediately when we start the program.Variables declared outside the body of a proctype are shared. The keyword show before a variable declaration will directSPIN to display the value as it changes.

Here, the two processes of deposit and withdraw can interleave arbitrarily. Regardless, with this very simple example,we will always get the same result balance.

To run the code, we use SPIN. We'll describe how to use the program xspin , which uses a graphical interface.More specifically, these instructions are for UNIX version 4.1.3. The PC and Mac versions are identical, except for how to startthe program. For details, see the program's README . Ask your local system administrator where the program is installedon your computer.

There is also a version based on the command-line, called spin . It is more difficult to use interactively, but is appropriatefor use non-interactive use, such as with scripts. For its options, see the manual pages for spin and the related pan . xspin is just a graphical front-end to spin . The underlying spin commands and output are displayed atthe bottom of the main xspin window. These can be ignored.
To run either xspin or spin from Rice University's Owlnet, first type setenv PATH /home/comp607/bin:$PATH .

Within SPIN, you'll work with a Promela program. If you already have a Promela program saved, you can open it withthe "File" menu's "Open" option. Alternatively, start SPIN with the Promela program's filename: xspin filename .pml (The conventional suffix for Promela programs is .pml .) Either of these loads the Promela code into an editor window,where it can be modified. To create a new program, you can type into this window, or you cancopy and past it from another editor.

Questions & Answers

what is defense mechanism
Chinaza Reply
what is defense mechanisms
Chinaza
I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Model checking concurrent programs. OpenStax CNX. Oct 27, 2005 Download for free at http://cnx.org/content/col10294/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Model checking concurrent programs' conversation and receive update notifications?

Ask