MODEX -- EXAMPLES -- Bell Laboratories, January 2003
====================================================

For a complete description of the construction of
Feaver/Modex test harnesses (.prx files) read the file

	../Doc/feaver.pdf

To be able to execute the example applications in this directory
you need to have the commands 'modex' and 'spin' (version 4)
in your search path, and you have the usual bevy of Unix
tools available (rm, mv, cp, and an ANSI-C compiler).
Strongly recommended is to work with the cygwin distribition
which is available freely from

	www.cygwin.com

The latest version of Spin can always be obtained from

	http://spinroot.com/Bin/index.html

A shell command script called 'feaver_cmd' and a graphical user
interface called 'feaver_gui' are included:

	../Scripts/feaver_cmd
	../Scripts/feaver_gui

The directory contains some small examples of C source
files with matching Modex test harness definitions:

	abp.c		abp.prx
	abp2.c		abp2.prx
	bounds.c	bounds.prx
	mutex.c		mutex.prx
	pointers.c	pointers.prx
	prod_cons.c	prod_cons.prx
	prod_cons2.c	prod_cons2.prx
	sape0.c		sape0.prx
	sape1.c		sape1.prx
	sape2.c		sape2.prx
	susp_lock.c	susp_lock.prx
	sw_race.c	sw_race.prx
	threads.c	threads.prx

To execute a test from the command-line, you can execute
the sequence of commands via the makefile, e.g.:

	make abp

You can also do this by hand by saying:

	make clean		# to first cleanup temporary files from previous runs
	../Scripts/feaver_cmd abp.prx	# to extract the model and run the verification

'feaver_cmd' is a shell script that tries to execute the following
command sequence, until an error is encountered, or the script completes:

	modex abp.prx		# to generate all necessary files
	sh _modex_.run		# to compile and execute
	sh _modex_.cln		# to clean up all debris

'_modex_.run' and '_modex_.cln' are shell scripts that are
generated by 'modex'.  the first does something like:

	cc -E -P _modex_*.drv > model
	spin -a model		# spin v4
	cc ... -o pan pan.c	# compile
	pan -n ...		# run
	pan -r			# replay error, if any

Note that replaying the error trail is done with the executable pan.
(It cannot be done with spin -t because of the embedded c-code.)

==================================
Gerard J. Holzmann, 8 January 2003


Fixes made on Aug 8, 2005:
==========================
Small changes to sape[012].c to fix a problem that had gone
undetected so far: allowing calls to cas() to appear as
conditionals (cast as c_expr) will not work since the call
has a side-effect -- while c_expr is assumed to be side
effect free.  Rewrote the C code slightly to avoid this.
Also made a fix in Scripts/feaver_cmd to make sure the
script finds the counter-example trail file if one exists.
