<< Chapter < Page Chapter >> Page >

Function calls are another standard kind of control flow. Surprisingly, Promela does not have function calls ! Every proctype instance is a separate process. Though if you really want, you could simulate a function call by creating a new process dynamically , and blocking until that process returns.

Verification

So far, we have determined the possible behaviors of a program simply by running the program abunch of times. For small programs, we can be very careful and make sure we exhibit all the possible traces, but the state spacesoon becomes unwieldy.

The real power of SPIN is as a tool for verification, our original goal.SPIN will search the entire state space for us , looking for (reachable) states which fail to have desired properties.

Assertions

The first verification technique we'll examine are assertion s, common to many programming languages. In Promela, the statement assert( condition ); evaluates the condition. If the result is true, execution continues as usual. Otherwise, the entire programis aborted and an error message is printed.

When simulating a single run of the program, SPIN automatically checks these run-time assertions;this is the usage that most programmers should be familiar with from traditional programming languages.But additionally, we'll see that SPIN, in the course of searching the entire state space,verifies whether an assertion can ever fail! (Though of course it can only search finite, feasible state spaces;happily,feasiblecan often include hundreds of millions of states.)

Consider our last race condition example . One of our original nave expectations was that, within each process,the value of z at the end of the process is exactly one more than at the beginning.The previous examples have shown that to be wrong, but we had to run the program until we encountered a run when it failed.Here, the assert statement puts that expectation explicitly into the program, for SPIN to check. 1 #define NUM_PROCS 3 23 show int z = 0; 45 active[NUM_PROCS] proctype increment()6 { 7 show int new_z;8 9 /* A saved copy of the old z, for the assertion. */10 show int old_z; 1112 old_z = z; 13 new_z = old_z + 1;14 z = new_z; 1516 assert(z == old_z+1); 17 }

It is often the case, as it is here, that to state the desired condition we need to add an extra variablehere, old_z . As always, it is important that when introducing such code fortesting that you don't substantially change the code to be tested, lest you inadvertently introduce new bugs!

Run this code several times, and observe when the assertion fails.This text indicates which assertion failed, and the line will be highlighted in the code window. To see which process' copy of increment failed and why, you have to look more closely at the steps shown. spin: line 16 "pan_in", Error: assertion violated spin: text of failed assertion: assert((z==(old_z+1)))

Questions & Answers

how can chip be made from sand
Eke Reply
is this allso about nanoscale material
Almas
are nano particles real
Missy Reply
yeah
Joseph
Hello, if I study Physics teacher in bachelor, can I study Nanotechnology in master?
Lale Reply
no can't
Lohitha
where is the latest information on a no technology how can I find it
William
currently
William
where we get a research paper on Nano chemistry....?
Maira Reply
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
Ali
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
Google
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
hey
Giriraj
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
revolt
da
Application of nanotechnology in medicine
has a lot of application modern world
Kamaluddeen
yes
narayan
what is variations in raman spectra for nanomaterials
Jyoti Reply
ya I also want to know the raman spectra
Bhagvanji
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
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