[Pntool-developers] SF.net SVN: pntool:[251] pnheaders
Brought to you by:
compaqdrew,
miordache
|
From: <mio...@us...> - 2011-07-15 15:22:15
|
Revision: 251
http://pntool.svn.sourceforge.net/pntool/?rev=251&view=rev
Author: miordache
Date: 2011-07-15 15:22:06 +0000 (Fri, 15 Jul 2011)
Log Message:
-----------
new software version
Modified Paths:
--------------
Makefile
doc/input2.sp
pnheaders/general.c
pnheaders/general.h
pnheaders/pns.c
pnheaders/pns.h
Added Paths:
-----------
Makefile_old.mak
doc/format2.hl
examples-old/
examples-old/+README+
examples-old/catandmouse.sp
examples-old/loop.sp
examples-old/loop3.sp
examples-old/reader.sp
examples-old/test.sp
examples-old/test2.sp
examples-old/test2a.sp
examples-old/test2b.sp
examples-old/test2c.sp
examples-old/test2d.sp
examples-old/test2e.sp
examples-old/test2f.sp
examples-old/test2g.sp
examples-old/test3a.sp
examples-old/test3b.sp
examples-old/test3c.sp
examples-old/test3d.sp
parser/
parser/Makefile
parser/actions.c
parser/dict.c
parser/dict.h
parser/read.h
parser/read.lex
parser/read.y
pnheaders/main_function2.c
Removed Paths:
-------------
examples/+README+
examples/catandmouse.sp
examples/loop.sp
examples/loop3.sp
examples/reader.sp
examples/test.sp
examples/test2.sp
examples/test2a.sp
examples/test2b.sp
examples/test2c.sp
examples/test2d.sp
examples/test2e.sp
examples/test2f.sp
examples/test2g.sp
examples/test3a.sp
examples/test3b.sp
examples/test3c.sp
examples/test3d.sp
Modified: Makefile
===================================================================
--- Makefile 2011-06-20 23:01:38 UTC (rev 250)
+++ Makefile 2011-07-15 15:22:06 UTC (rev 251)
@@ -6,11 +6,11 @@
SPNBOX=spnbox
CODEGEN=newcodegen
CODEGENOBJS = $(CODEGEN)
-TRANSLATOR=translator
+TRANSLATOR=parser
-ct: objectfiles main_function.o
+ct: objectfiles main_function2.o
$(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \
- main_function.o $(SPNBOX)/*.a $(TRANSLATOR)/libtranslator.a
+ main_function2.o $(SPNBOX)/*.a $(TRANSLATOR)/*.o
objectfiles:
cd $(PNHEADERS); make
@@ -18,11 +18,11 @@
cd $(SPNBOX); make
cd $(TRANSLATOR); make
-main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/codegen.h
- $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox -I$(CODEGEN) -I$(PNHEADERS)
+main_function2.o: $(PNHEADERS)/main_function2.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/codegen.h
+ $(COMPILER) -c $(PNHEADERS)/main_function2.c -Ispnbox -I$(CODEGEN) -I$(PNHEADERS)
clean:
- rm -f main_function.o
+ rm -f main_function2.o
cd $(PNHEADERS); make clean
cd $(CODEGEN); make clean
cd $(TRANSLATOR); make clean
Copied: Makefile_old.mak (from rev 250, Makefile)
===================================================================
--- Makefile_old.mak (rev 0)
+++ Makefile_old.mak 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,34 @@
+# This is the make file of the old version (the one that uses the translator)
+
+COMPILER=gcc -g
+
+PNHEADERS=pnheaders
+SPNBOX=spnbox
+CODEGEN=newcodegen
+CODEGENOBJS = $(CODEGEN)
+TRANSLATOR=translator
+
+ct: objectfiles main_function.o
+ $(COMPILER) -o ct $(PNHEADERS)/*.o $(CODEGENOBJS)/*.o $(SPNBOX)/*.o \
+ main_function.o $(SPNBOX)/*.a $(TRANSLATOR)/libtranslator.a
+
+objectfiles:
+ cd $(PNHEADERS); make
+ cd $(CODEGEN); make static
+ cd $(SPNBOX); make
+ cd $(TRANSLATOR); make
+
+main_function.o: $(PNHEADERS)/main_function.c $(PNHEADERS)/pns.h $(SPNBOX)/spnbox.h $(CODEGEN)/codegen.h
+ $(COMPILER) -c $(PNHEADERS)/main_function.c -Ispnbox -I$(CODEGEN) -I$(PNHEADERS)
+
+clean:
+ rm -f main_function.o
+ cd $(PNHEADERS); make clean
+ cd $(CODEGEN); make clean
+ cd $(TRANSLATOR); make clean
+ cd $(SPNBOX); make clean
+
+distclean: clean
+ cd $(CODEGEN); make distclean
+ cd $(TRANSLATOR); make distclean
+
Added: doc/format2.hl
===================================================================
--- doc/format2.hl (rev 0)
+++ doc/format2.hl 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,188 @@
+// This file describes the specification language.
+// July 6, 2011.
+
+// In this document both threads and processes are called processes.
+
+// The specification describes processes and how they should be coordinated.
+// The program implementing the specification consists of a coordinator
+// that runs the processes described in the specification and supervises
+// their execution. The coordinator is called supervisor.
+
+// The specification defines groups of processes. A group may have any number
+// of processes (0, 1, 2, ...). This number may change during the execution of
+// the program. The specification determines the initial number of processes
+// in a group and how this number may change. Processes in a group are
+// identical in the sense that they have the same executable code. However,
+// processes in the same group do not have to be in the same stage of
+// execution.
+
+// A group of processes is implemented by means of executable programs if
+// it is defined with the keyword "process". Otherwise, it is implemented
+// by means of threads of the supervisor if it is defined with the keyword
+// "thread".
+
+// The following defines a group or processes
+
+process p1 {
+
+ // The following defines the Petri net representation of the process
+
+ places: p1 p2 p3
+ transitions: t0
+ transitions: t1 t2 t3 t4
+
+ // The following describes the arcs connecting places and transitions
+
+ (p1, t0)
+ (p1, t1, p3)
+
+ // A semicolon must be used between instructions on the same row
+
+ (p3, t4, p1); (t3, p3)
+
+ // The following arc is conditional. The generated program will
+ // contain an "if(i >= 1)" instruction before attempting to fire t2. Thus,
+ // the variable i must be defined in the context of the C code associated
+ // with the place p2.
+
+ (p2, t2) {i >= 1}
+
+}
+
+// The following defines a group or processes implemented as threads
+
+
+thread t1 {
+
+ // The following defines the Petri net representation of the process
+
+ places: p1 p2 p3
+ transitions: t1 t2 t3 t4
+
+ // The following describes the arcs connecting places and transitions
+
+ (p1, t1)
+ (p1, t2, p3)
+ (p3, t3, p2); (p2, t4, p1);
+
+}
+
+
+// The Petri net associated with a supervisor is generated automatically.
+// However, the user has the option to specify additional components to be
+// included in the Petri net of the supervisor. The following block defines
+// such a component.
+
+supervisor sc {
+ places: p1 p2
+ transitions: t1
+
+ (p1, t1, p2)
+}
+
+
+// The following synchronizes the transition t1 of process p1 with the
+// transition t3 of the process t1.
+
+sync p1.t1 t1.t3
+
+// Constraints can be described by means of inequalities
+
+2*p1.q.t2 - t1.p3 <= 1 // firing vector element: process.q.transition
+ // marking vector element: process.place
+
+t1.v.t1 <= t1.v.t2 // Parikh vector element: process.v.transition
+
+
+// The following describes the initial number of processes in each group.
+// It also describes the stage in which each process should be started.
+
+initialize: p1(p1:1, p2:2)
+initialize: t1(p2:1) sc(p1:5)
+
+// The group p1 will have three processes: one starting in p1 and two starting
+// in p2. The group t1 will have only one process and that process will start
+// in p2. Now, sc is not a process group but a supervisor component. The
+// initialization of sc requests that the Petri net of sc will have an initial
+// marking with 5 tokens in p1.
+
+// By default, a group of processes is initialized with zero processes.
+
+// Transitions that should be live can be specified as follows.
+// NOTE: Avoid this instruction when possible, since the synthesis of a
+// deadlock prevention policy is computationally intensive and can take much
+// time.
+
+live: t1.t2 // the supervisor should ensure that the transition t2 of the
+ // process group t1 is live.
+
+
+// The following blocks are OPTIONAL.
+
+// A segment of code can be associated with each place. The following
+// instruction defines the code of the place p3 of the process p1.
+
+p1.p3 {
+ i = i + 1;
+ j = 10*i;
+}
+
+// Any instructions that a process should execute when it is started
+// can be specified by means of a main block
+
+p1.main {
+ i = 0;
+ j = 1;
+}
+
+// Header files and other definitions that should appear in the source file of
+// a process can be specified by means of an include block
+
+p1.include {
+ #include"string.h"
+ #define MAX 10
+
+ int i, j;
+
+ struct myarray { int i; float k; };
+
+ static struct myarray array[MAX];
+}
+
+// Instructions on how to build the executable file associated with a process
+// can be specified in a build block. Note that the software will replace $$$
+// with the name of the file defining the process (without extension).
+
+p1.build { gcc -g -o $$$.exe $$$.c }
+
+// Copies of a process group can be specified as follows
+
+p1c = p1 // p1c is another process group
+
+// Note that p1 has been defined with the keyword 'process'. Thus, p1c will
+// also be of the type 'process'. If the copy should have a different type,
+// the desired type should be stated before the assignment.
+
+thread p1c2 = p1
+
+// On the line above, p1c2 is defined as a copy of p1 of the type 'thread'.
+
+// Instructions that the supervisor should execute when it is started
+// can be specified by means of a main block
+
+main {
+ fprintf(stdout, "The supervisor is starting ...");
+}
+
+// An include block can also be defined for the supervisor
+
+include {
+ #define MAX_INP 3
+ #include"ctype.h"
+}
+
+
+// The build block of the supervisor can be used to specify additional
+// command line parameters that should be used when building the program
+
+build { -I. }
Modified: doc/input2.sp
===================================================================
--- doc/input2.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ doc/input2.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,4 +1,5 @@
-// This is a preliminary description of the low level specification language.
+// THIS DOCUMENT DESCRIBES THE *OLD* VERSION OF THE SPECIFICATION LANGUAGE.
+// SEE format2.hl FOR A DESCRIPTION OF THE CURRENT SPECIFICATION LANGUAGE.
// FOR REFERENCE ONLY. ON ONE HAND, NOT ALL FEATURES HAVE BEEN IMPLEMENTED
// IN THE TRANSLATOR. ON THE OTHER HAND, SOME IMPLEMENTED FEATURES ARE NOT
Deleted: examples/+README+
===================================================================
--- examples/+README+ 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/+README+ 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,44 +0,0 @@
-
-Here is the list of test examples:
-
-loop.sp: illustrates how to create loops
-
-loop3.sp: illustrates how to create loops and how to specify code for the main function of the generated program.
-
-
-test2.sp: When running this example a single process (not thread) is started. The process prints messages indicating its state until it terminates.
-
-Variants:
-
-test2a.sp: a single processes (not thread) is started.
-
-test2b.sp: several identical processes (not threads) are started.
-
-test2c.sp: only one thread (not forked process) will run this time.
-
-test2d.sp: multiple threads (not forked processes) will run this time.
-
-test2e.sp: synchronization by means of transitions between single threads.
-
-test2f.sp: synchronization by means of transitions between multiple threads.
-
-test2g.sp: same as test2f.sp except for using forked processes (not threads).
-
-
-
-test3: A dining philosopher example.
-
-test3a.sp: Tests that the deadlock prevention function works fine when no deadlock is possible. Only one philosopher with two resources.
-
-test3b.sp: A test involving two philosophers.
-
-test3c.sp: A test involving 5 philosophers.
-
-test3d.sp: A test involving 5 philosophers. Here, the resources (chopsticks) are defined as supervisor components, not as threads.
-
-
-
-reader.sp: A reader, inserter, deleter problem.
-
-
-catandmouse.sp: This is the cat and mouse maze example. Implemented by Micah Martin.
Deleted: examples/catandmouse.sp
===================================================================
--- examples/catandmouse.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/catandmouse.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,116 +0,0 @@
-// This is a cat and mouse room example
-
-process CAT;
-build: {<thread>};
-
-process MOUSE;
-build: {<thread>};
-
-CAT.PN:
-
-places: p1 p2 p3 p4 p5;
-
-transitions: c1 c2 c3 c4 c5 c6 c7 c8;
-
-// This function defines the places a cat can go.
-
-p1.code: {
-// Room 1
- fprintf(stderr, "\n\nCat is in Room 1");
- sleep(1);
-};
-
-p2.code: {
-// Room 2
- fprintf(stderr, "\n\nCat is in Room 2");
- sleep(1);
-};
-
-p3.code: {
-// Room 3
- fprintf(stderr, "\n\nCat is in Room 3");
- sleep(1);
-};
-
-p4.code: {
-// Room 4
- fprintf(stderr, "\n\nCat is in Room 4");
- sleep(1);
-};
-
-p5.code: {
-// Room 5
- fprintf(stderr, "\n\nCat is in Room 5");
- sleep(1);
-};
-
-(p1, c1, p2);
-(p2, c2, p3);
-(p3, c3, p1);
-(p1, c4, p4);
-(p4, c5, p5);
-(p5, c6, p1);
-(p2, c7, p4);
-(p4, c8, p2);
-
-
-MOUSE.PN:
-
-places: p6 p7 p8 p9 p10;
-
-transitions: m1 m2 m3 m4 m5 m6;
-
-// This function defines the places a mouse can go.
-
-p6.code: {
-// Room 1
- fprintf(stderr, "\n\nMouse is in Room 1");
- sleep(1);
-};
-
-p7.code: {
-// Room 2
- fprintf(stderr, "\n\nMouse is in Room 2");
- sleep(1);
-};
-
-p8.code: {
-// Room 3
- fprintf(stderr, "\n\nMouse is in Room 3");
- sleep(1);
-};
-
-p9.code: {
-// Room 4
- fprintf(stderr, "\n\nMouse is in Room 4");
- sleep(1);
-};
-
-p10.code: {
-// Room 5
- fprintf(stderr, "\n\nMouse is in Room 5");
- sleep(1);
-};
-
-(p6, m1, p8);
-(p8, m2, p7);
-(p7, m3, p6);
-(p6, m4, p10);
-(p10, m5, p9);
-(p9, m6, p6);
-
-
-CAT cat(p3:1); // defines one cat initialized in Room 3
-MOUSE mouse(p10:1); // defines one mouse initialized in Room 5
-
-
-
-global.constraints:
-
-// No room can contain a cat and mouse simultaneously
-
-cat.p1 + mouse.p6 <= 1;
-cat.p2 + mouse.p7 <= 1;
-cat.p3 + mouse.p8 <= 1;
-cat.p4 + mouse.p9 <= 1;
-cat.p5 + mouse.p10 <= 1;
\ No newline at end of file
Deleted: examples/loop.sp
===================================================================
--- examples/loop.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/loop.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,38 +0,0 @@
-// This is an example illustrating conditional transitions and loops.
-
-
-
-process MLOOP;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- static int i = 0; // 'i' shared by threads in the same group; the 'static'
- // keyword ensures that it is not visible to other threads
-};
-
-MLOOP.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-(p0, t0, p1);
-(p1, t1, p0).{i < 4}; // Transition takes place only if i < 4.
-(p1, t2).{i >= 4}; // exit via t2 if i is greater than 4.
-
-p0.code: {
- fprintf(stderr, "\nState 0, i = %d", i);
- fflush(0);
- sleep(1);
- i++;
-};
-
-p1.code: {
- fprintf(stderr, "\nState 1, i = %d", i);
- fflush(0);
- sleep(1);
-};
-
-MLOOP pr1(p0:1);
Deleted: examples/loop3.sp
===================================================================
--- examples/loop3.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/loop3.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,159 +0,0 @@
-
-process SPR;
-
-build: {<supervisor>};
-
-include: {
- #include<stdio.h>
- int result, N; // these will be used as shared variable
- int a[10]; // declares a shared array of 10 integers
-
-<main>
-
- // <main> indicates that what follows is part of the main function of the
- // supervisor.
-
- N = 5;
- result = 0;
-
- /* The following function call will execute the code of the supervisor,
- which in turn will start and execute the code of the specified processes
- and/or threads. */
-
- ___run_supervisor();
-
- // The result of the program is verified:
-
- printf("\nThe result is %d. The expected result was %d.\n", result, 3*N);
-
- // A return instruction is ESSENTIAL when the code calls
- // ___run_supervisor(). Otherwise, this function will be called again by
- // the default instructions of the generated code.
-
- return 0;
-};
-
-
-process LOOP_1;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- extern int result;
- extern int N;
- extern int a[];
- static int i;
- static int j;
-
- // 'extern' indicates a variable defined in another C file of the project
- // 'static' defines a variable invisible to the other C files of the project
-
-<main> // This indicates code for the main function of the thread
-
- fprintf(stderr, "\nA LOOP_1 thread was started.");
- fflush(0);
- i = 0;
-
-};
-
-
-process LOOP_2;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- extern int result;
- extern int N;
- static int i;
- static int j;
-
- // 'extern' indicates a variable defined in another C file of the project
- // 'static' defines a variable invisible to the other C files of the project
-
-<main> // This indicates code for the main function of the thread
-
- fprintf(stderr, "\nA LOOP_2 thread was started.");
- fflush(0);
- i = 0;
-
-};
-
-
-
-SPR.PN:
-
-places: p0;
-
-transitions: t0;
-
-(p0, t0);
-
-
-
-
-LOOP_1.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-(p0, t0, p1);
-(p1, t1, p0).{i < N}; // Transition takes place only if i < N.
-(p1, t2).{i >= N}; // exit via t2 if i is greater than N.
-
-p0.code: {
- fprintf(stderr, "\nLOOP_1: State 0, i = %d", i);
- fflush(0);
- sleep(1);
- i++;
-};
-
-p1.code: {
- j = result + 1;
- fprintf(stderr, "\nLOOP_1: State 1, i = %d", i);
- fflush(0);
- sleep(1);
- result = j;
-};
-
-
-
-LOOP_2.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-(p0, t0, p1);
-(p1, t1, p0).{i < N}; // Transition takes place only if i < N.
-(p1, t2).{i >= N}; // exit via t2 if i is greater than N.
-
-p0.code: {
- fprintf(stderr, "\nLOOP_2: State 0, i = %d", i);
- fflush(0);
- sleep(1);
- i++;
-};
-
-p1.code: {
- j = result + 2;
- fprintf(stderr, "\nLOOP_2: State 1, i = %d", i);
- fflush(0);
- sleep(1);
- result = j;
-};
-
-
-
-
-
-LOOP_1 a(p0:1);
-LOOP_2 b(p0:1);
-SPR sp;
-
-
-global.constraints:
-
-a.p1 + b.p1 <= 1; // implement mutual exclusion
Deleted: examples/reader.sp
===================================================================
--- examples/reader.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/reader.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,124 +0,0 @@
-// This is a reader/writer/inserter example
-
-process READER;
-build: {<thread>};
-
-process DELETER;
-build: {<thread>};
-
-process INSERTER;
-build: {<thread>};
-
-READER.PN:
-
-places: pv pc pd;
-
-transitions: tv tc td;
-
-// The main function for a thread/process defines a void* type pointer p___ initialized to zero.
-// This is useful when several copies of a thread run in parallel, so that each thread copy
-// has a known variable to allocate so that it can save its own data. Further, an initialization
-// function can be called if p___ = 0.
-
-pv.code: {
-//evaluate_data(&p___);
- debugInfo("READER: Entering the evaluation block");
- sleep(1);
-};
-
-pc.code: {
-//read_data(&p___);
- debugInfo("READER: Entering the read block");
- sleep(1);
- debugInfo("READER: Exiting the read block");
-};
-
-pd.code: {
-//process_data(&p___);
- debugInfo("READER: Entering the processing block");
- sleep(1);
-};
-
-(pv, tv, pc);
-(pc, tc, pd);
-(pd, td, pv);
-
-
-DELETER.PN:
-
-places: pv pc pd;
-
-transitions: tv tc td;
-
-pv.code: {
-//d_evaluate_data(&p___);
- debugInfo("DELETER: Entering the evaluation block");
- sleep(1);
-
-};
-
-pc.code: {
-//delete_data(&p___);
- debugInfo("DELETER: Entering the read block");
- sleep(1);
- debugInfo("DELETER: Exiting the read block");
-
-};
-
-pd.code: {
-//d_process_data(&p___);
- debugInfo("DELETER: Entering the processing block");
- sleep(1);
-
-};
-
-(pv, tv, pc);
-(pc, tc, pd);
-(pd, td, pv);
-
-
-INSERTER.PN:
-
-places: pv pc pd;
-
-transitions: tv tc td;
-
-pv.code: {
-//i_evaluate_data(&p___);
- debugInfo("INSERTER: Entering the evaluation block");
- sleep(1);
-};
-
-pc.code: {
-//insert_data(&p___);
- debugInfo("INSERTER: Entering the read block");
- sleep(1);
- debugInfo("INSERTER: Exiting the read block");
-};
-
-pd.code: {
-//i_process_data(&p___);
- debugInfo("INSERTER: Entering the processing block");
- sleep(1);
-};
-
-(pv, tv, pc);
-(pc, tc, pd);
-(pd, td, pv);
-
-
-READER read(pv:5); // defines five reader processes starting in state pv
-INSERTER insert(pv:3);
-DELETER delete(pv:3);
-
-
-global.constraints:
-
-insert.pc <= 1;
-
-// delete.pc <= 1; // not necessary: see constraint below
-
-// The following should be read.pc + insert.pc + 6*delete.pc <= 6
-// However, the translator has a bug preventing it from recognizing multipliers
-
-read.pc + insert.pc + delete.pc + delete.pc + delete.pc + delete.pc + delete.pc + delete.pc<= 6; // 6 is max(reader.pc + inserter.pc)
Deleted: examples/test.sp
===================================================================
--- examples/test.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,23 +0,0 @@
-// This is a test file created in order to check the functionality of the
-// pn translator.
-
-process TST;
-
-include: {
- int i;
-};
-
-TST.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2;
-
-(p0, t0);
-(t2, p0);
-(p1, t1, p2, p0); // this is not a state machine;
-(p1, t1, p2, p0); // the code generator assumes state machines.
-(p2, t2, p1).{i == 3};
-
-TST testpn(p0:2,p1:1);
-
Deleted: examples/test2.sp
===================================================================
--- examples/test2.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,126 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {gcc -g -o $$$.exe $$$.c};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN: State 0 u = %d", u);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1");
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2");
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- u++;
- printf("\nPN3: State 0 u = %d", u);
- delay(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- delay(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:1);
-
-PN3 pr2;
-
Deleted: examples/test2a.sp
===================================================================
--- examples/test2a.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2a.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,126 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {gcc -g -o $$$.exe $$$.c};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN: State 0 u = %d", u);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1");
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2");
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- u++;
- printf("\nPN3: State 0 u = %d", u);
- delay(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- delay(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:1);
-
-PN3 pr2;
-
Deleted: examples/test2b.sp
===================================================================
--- examples/test2b.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2b.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,126 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {gcc -g -o $$$.exe $$$.c};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN: State 0 u = %d", u);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1");
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2");
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- u++;
- printf("\nPN3: State 0 u = %d", u);
- delay(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- delay(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:3,p1:0,p2:0);
-
-PN3 pr2;
-
Deleted: examples/test2c.sp
===================================================================
--- examples/test2c.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2c.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,126 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int v = 0;
-
- void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN: State 0 u = %d", u);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1");
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2");
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- v--;
- printf("\nPN3: State 0 v = %d", v);
- delay2(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- delay2(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:1);
-
-PN3 pr2;
-
Deleted: examples/test2d.sp
===================================================================
--- examples/test2d.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2d.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,126 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int v = 0;
-
- void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN: State 0 u = %d", u);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1");
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2");
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- v--;
- printf("\nPN3: State 0 v = %d", v);
- delay2(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- delay2(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:4);
-
-PN3 pr2;
-
Deleted: examples/test2e.sp
===================================================================
--- examples/test2e.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2e.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,134 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int v = 0;
-
- void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN: State 0 u = %d", u);
- fflush(0);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1");
- fflush(0);
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2");
- fflush(0);
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- v--;
- printf("\nPN3: State 0 v = %d", v);
- fflush(0);
- delay2(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- fflush(0);
- delay2(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:1);
-
-PN3 pr2;
-
-sync pr1.t1 pr2.t2;
-sync pr1.t4 pr2.t2;
-sync pr1.t2 pr2.t1;
Deleted: examples/test2f.sp
===================================================================
--- examples/test2f.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2f.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,134 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int v = 0;
-
- void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN: State 0 u = %d", u);
- fflush(0);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1");
- fflush(0);
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2");
- fflush(0);
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- v--;
- printf("\nPN3: State 0 v = %d", v);
- fflush(0);
- delay2(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- fflush(0);
- delay2(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:4);
-
-PN3 pr2;
-
-sync pr1.t1 pr2.t2;
-sync pr1.t4 pr2.t2;
-sync pr1.t2 pr2.t1;
Deleted: examples/test2g.sp
===================================================================
--- examples/test2g.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test2g.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,134 +0,0 @@
-// This is a test file intended to check the code generation module
-// The example of this file was adapted from compexample.c
-
-process TYPE1;
-
-build: {gcc -g -o $$$.exe $$$.c};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-
- int f1(int z) {
- struct ___trans ___TR[1];
- if(u > 5) {
- ___TR[0].no_output = 1;
- ___TR[0].label = -4;
- ___TR[0].trans = 3;
- }
- else {
- ___TR[0].no_output = 0;
- ___TR[0].label = -2;
- ___TR[0].trans = 1;
- ___TR[0].place = 2;
- }
- return 1;
- }
-};
-
-
-process PN3;
-
-build: {gcc -g -o $$$.exe $$$.c};
-
-include: {
- #include<stdio.h>
- int v = 0;
-
- void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-TYPE1.PN:
-
-places: p0 p1 p2;
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPN (%d): State 0 u = %d", (int) getpid(), u);
- //fflush(0);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN (%d): State 1", (int) getpid());
- //fflush(0);
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN (%d): State 2", (int) getpid());
- //fflush(0);
- delay(1);
-};
-
-
- // Let's create the following PN:
- //
- // t2
- // -------|<----
- // | p0 p1 |p2
- // ->O->|->O->|->O<--
- // | t0 | t1 |
- // | | |
- // | V |
- // | --- t3 |
- // | |
- // ------>|-------
- // t4
-
-(p0, t4, p2);
-(p1, t3);
-(p2, t2, p0);
-(p1, t1, p2);
-(p0, t0, p1);
-
-PN3.PN:
-
-places: p0 p1;
-
-transitions: t0 t1 t2;
-
-p0.code: {
- v--;
- printf("\nPN3: State 0 v = %d", v);
- //fflush(0);
- delay2(2);
-};
-
-p1.code: {
- printf("\nPN3: State 1");
- //fflush(0);
- delay2(2);
-};
-
- // Let's create this PN:
- //
- // p0 p1
- // |->O->|->O->|
- // t2 t0 t1
- //
-
-(t2, p0);
-(p0, t0, p1);
-(p1, t1);
-
-
-
-TYPE1 pr1(p0:4);
-
-PN3 pr2;
-
-sync pr1.t1 pr2.t2;
-sync pr1.t4 pr2.t2;
-sync pr1.t2 pr2.t1;
Deleted: examples/test3a.sp
===================================================================
--- examples/test3a.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test3a.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,105 +0,0 @@
-// This is a test file intended to check the code generation module
-
-process PHIL;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- int pr1_state = 0, i, j, u = 0;
-
- void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-
-process RESOURCE;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- static int v = 0;
-
- static void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-PHIL.PN:
-
-places: p0 p1 p2 p3; // think, request right fork, request left fork, eat
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPhil. State 0 (think) u = %d", u);
- fflush(0);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1 (requesting right fork)");
- fflush(0);
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2 (requesting left fork)");
- fflush(0);
- delay(1);
-};
-
-p3.code: {
- fprintf(stderr, "\nPN: State 3 (eat)");
- fflush(0);
- delay(1);
-};
-
-(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0);
-
-// t3
-// ------------|<---------------
-// | |
-// ->O-->|-->O-->|-->O-->|-->O--
-// p0 t0 p1 t1 p2 t2 p3
-
-
-RESOURCE.PN:
-
-places: p;
-
-transitions: t0 t2;
-
-// --->| t2
-// p |
-// t0 |--->O
-//
-
-
-(p, t2); (t0, p);
-
-p.code: {
- fprintf(stderr, "\nResource %s is available", ___NAME);
- fflush(0);
-};
-
-RESOURCE left(p:1);
-RESOURCE right(p:1);
-
-PHIL ph1(p0:1);
-
-sync ph1.t1 left.t2;
-sync ph1.t2 right.t2;
-sync ph1.t3 left.t0;
-sync ph1.t3 right.t0;
-
-ph1.constraints:
-
-live: t1;
Deleted: examples/test3b.sp
===================================================================
--- examples/test3b.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test3b.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,113 +0,0 @@
-// This is a test file intended to check the code generation module
-
-process PHIL;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- static int pr1_state = 0, i, j, u = 0;
-
- static void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-
-process RESOURCE;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- static int v = 0;
-
- static void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-PHIL.PN:
-
-places: p0 p1 p2 p3; // think, request right fork, request left fork, eat
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\nPhil. State 0 (think) u = %d", u);
- fflush(0);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\nPN: State 1 (requesting right fork)");
- fflush(0);
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\nPN: State 2 (requesting left fork)");
- fflush(0);
- delay(1);
-};
-
-p3.code: {
- fprintf(stderr, "\nPN: State 3 (eat)");
- fflush(0);
- delay(1);
-};
-
-(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0);
-
-// t3
-// ------------|<---------------
-// | |
-// ->O-->|-->O-->|-->O-->|-->O--
-// p0 t0 p1 t1 p2 t2 p3
-
-
-RESOURCE.PN:
-
-places: p;
-
-transitions: t0 t1 t2 t3;
-
-// --->| t2
-// p |
-// t0 |--->O<---| t1
-// |
-// --->| t3
-
-
-(p, t2); (p, t3); (t0, p); (t1, p);
-
-p.code: {
- fprintf(stderr, "\nResource %s is available", ___NAME);
- fflush(0);
-};
-
-RESOURCE left(p:1);
-RESOURCE right(p:1);
-
-PHIL ph1(p0:1);
-PHIL ph2(p0:1);
-
-sync ph1.t1 left.t2;
-sync ph2.t1 right.t2;
-sync ph1.t2 right.t3;
-sync ph2.t2 left.t3;
-sync ph1.t3 left.t0;
-sync ph1.t3 right.t0;
-sync ph2.t3 left.t1;
-sync ph2.t3 right.t1;
-
-ph1.constraints:
-live: t1;
-
-ph2.constraints:
-live: t1;
\ No newline at end of file
Deleted: examples/test3c.sp
===================================================================
--- examples/test3c.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test3c.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,113 +0,0 @@
-// This is a test file intended to check the code generation module
-
-process PHIL;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- static int pr1_state = 0, i, j, u = 0;
-
- static void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-
-process RESOURCE;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- static int v = 0;
-
- static void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-PHIL.PN:
-
-places: p0 p1 p2 p3; // think, request right fork, request left fork, eat
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\n%s (%s): State 0 (think) u = %d",___INSTANCE,___NAME, u);
- fflush(0);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\n%s (%s): State 1 (requesting right fork)",___INSTANCE,___NAME);
- fflush(0);
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\n%s (%s): State 2 (requesting left fork)",___INSTANCE,___NAME);
- fflush(0);
- delay(1);
-};
-
-p3.code: {
- fprintf(stderr, "\n%s (%s): State 3 (eat)",___INSTANCE,___NAME);
- fflush(0);
- delay(1);
-};
-
-(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0);
-
-// t3
-// ------------|<---------------
-// | |
-// ->O-->|-->O-->|-->O-->|-->O--
-// p0 t0 p1 t1 p2 t2 p3
-
-
-RESOURCE.PN:
-
-places: p;
-
-transitions: t0 t1 t2 t3;
-
-// --->| t2
-// p |
-// t0 |--->O<---| t1
-// |
-// --->| t3
-
-
-(p, t2); (p, t3); (t0, p); (t1, p);
-
-p.code: {
- fprintf(stderr, "\nResource %s is available", ___NAME);
- fflush(0);
-};
-
-RESOURCE r1(p:1); RESOURCE r2(p:1); RESOURCE r3(p:1); RESOURCE r4(p:1); RESOURCE r5(p:1);
-
-PHIL ph1(p0:1); PHIL ph2(p0:1); PHIL ph3(p0:1); PHIL ph4(p0:1); PHIL ph5(p0:1);
-
-sync ph1.t1 r1.t2; sync ph2.t1 r2.t2; sync ph3.t1 r3.t2; sync ph4.t1 r4.t2; sync ph5.t1 r5.t2;
-
-sync ph1.t2 r5.t3; sync ph2.t2 r1.t3; sync ph3.t2 r2.t3; sync ph4.t2 r3.t3; sync ph5.t2 r4.t3;
-
-sync ph1.t3 r1.t0 r5.t1; sync ph2.t3 r2.t0 r1.t1; sync ph3.t3 r3.t0 r2.t1; sync ph4.t3 r4.t0 r3.t1; sync ph5.t3 r5.t0 r4.t1;
-
-ph1.constraints:
-live: t1;
-ph2.constraints:
-live: t1;
-ph3.constraints:
-live: t1;
-ph4.constraints:
-live: t1;
-ph5.constraints:
-live: t1;
Deleted: examples/test3d.sp
===================================================================
--- examples/test3d.sp 2011-06-20 23:01:38 UTC (rev 250)
+++ examples/test3d.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -1,113 +0,0 @@
-// This is a test file intended to check the code generation module
-
-process PHIL;
-
-build: {<thread>};
-
-include: {
- #include<stdio.h>
- static int pr1_state = 0, i, j, u = 0;
-
- static void delay(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-
-process RESOURCE;
-
-build: {<supervisor>}; // code is ignored for supervisor components
-
-include: {
- #include<stdio.h>
- static int v = 0;
-
- static void delay2(int n) {
- time_t a, b;
- for(time(&a), time(&b); a + n > b; time(&b));
- }
-};
-
-
-PHIL.PN:
-
-places: p0 p1 p2 p3; // think, request right fork, request left fork, eat
-
-transitions: t0 t1 t2 t3 t4;
-
-p0.code: {
- u++;
- fprintf(stderr, "\n%s (%s): State 0 (think) u = %d",___INSTANCE,___NAME, u);
- fflush(0);
- delay(1);
-};
-
-p1.code: {
- fprintf(stderr, "\n%s (%s): State 1 (requesting right fork)",___INSTANCE,___NAME);
- fflush(0);
- delay(1);
-};
-
-p2.code: {
- fprintf(stderr, "\n%s (%s): State 2 (requesting left fork)",___INSTANCE,___NAME);
- fflush(0);
- delay(1);
-};
-
-p3.code: {
- fprintf(stderr, "\n%s (%s): State 3 (eat)",___INSTANCE,___NAME);
- fflush(0);
- delay(1);
-};
-
-(p0, t0, p1); (p1, t1, p2); (p2, t2, p3); (p3, t3, p0);
-
-// t3
-// ------------|<---------------
-// | |
-// ->O-->|-->O-->|-->O-->|-->O--
-// p0 t0 p1 t1 p2 t2 p3
-
-
-RESOURCE.PN:
-
-places: p;
-
-transitions: t0 t1 t2 t3;
-
-// --->| t2
-// p |
-// t0 |--->O<---| t1
-// |
-// --->| t3
-
-
-(p, t2); (p, t3); (t0, p); (t1, p);
-
-p.code: {
- fprintf(stderr, "\nResource %s is available", ___NAME);
- fflush(0);
-};
-
-RESOURCE r1(p:1); RESOURCE r2(p:1); RESOURCE r3(p:1); RESOURCE r4(p:1); RESOURCE r5(p:1);
-
-PHIL ph1(p0:1); PHIL ph2(p0:1); PHIL ph3(p0:1); PHIL ph4(p0:1); PHIL ph5(p0:1);
-
-sync ph1.t1 r1.t2; sync ph2.t1 r2.t2; sync ph3.t1 r3.t2; sync ph4.t1 r4.t2; sync ph5.t1 r5.t2;
-
-sync ph1.t2 r5.t3; sync ph2.t2 r1.t3; sync ph3.t2 r2.t3; sync ph4.t2 r3.t3; sync ph5.t2 r4.t3;
-
-sync ph1.t3 r1.t0 r5.t1; sync ph2.t3 r2.t0 r1.t1; sync ph3.t3 r3.t0 r2.t1; sync ph4.t3 r4.t0 r3.t1; sync ph5.t3 r5.t0 r4.t1;
-
-ph1.constraints:
-live: t1;
-ph2.constraints:
-live: t1;
-ph3.constraints:
-live: t1;
-ph4.constraints:
-live: t1;
-ph5.constraints:
-live: t1;
Copied: examples-old/+README+ (from rev 250, examples/+README+)
===================================================================
--- examples-old/+README+ (rev 0)
+++ examples-old/+README+ 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,44 @@
+
+Here is the list of test examples:
+
+loop.sp: illustrates how to create loops
+
+loop3.sp: illustrates how to create loops and how to specify code for the main function of the generated program.
+
+
+test2.sp: When running this example a single process (not thread) is started. The process prints messages indicating its state until it terminates.
+
+Variants:
+
+test2a.sp: a single processes (not thread) is started.
+
+test2b.sp: several identical processes (not threads) are started.
+
+test2c.sp: only one thread (not forked process) will run this time.
+
+test2d.sp: multiple threads (not forked processes) will run this time.
+
+test2e.sp: synchronization by means of transitions between single threads.
+
+test2f.sp: synchronization by means of transitions between multiple threads.
+
+test2g.sp: same as test2f.sp except for using forked processes (not threads).
+
+
+
+test3: A dining philosopher example.
+
+test3a.sp: Tests that the deadlock prevention function works fine when no deadlock is possible. Only one philosopher with two resources.
+
+test3b.sp: A test involving two philosophers.
+
+test3c.sp: A test involving 5 philosophers.
+
+test3d.sp: A test involving 5 philosophers. Here, the resources (chopsticks) are defined as supervisor components, not as threads.
+
+
+
+reader.sp: A reader, inserter, deleter problem.
+
+
+catandmouse.sp: This is the cat and mouse maze example. Implemented by Micah Martin.
Copied: examples-old/catandmouse.sp (from rev 250, examples/catandmouse.sp)
===================================================================
--- examples-old/catandmouse.sp (rev 0)
+++ examples-old/catandmouse.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,116 @@
+// This is a cat and mouse room example
+
+process CAT;
+build: {<thread>};
+
+process MOUSE;
+build: {<thread>};
+
+CAT.PN:
+
+places: p1 p2 p3 p4 p5;
+
+transitions: c1 c2 c3 c4 c5 c6 c7 c8;
+
+// This function defines the places a cat can go.
+
+p1.code: {
+// Room 1
+ fprintf(stderr, "\n\nCat is in Room 1");
+ sleep(1);
+};
+
+p2.code: {
+// Room 2
+ fprintf(stderr, "\n\nCat is in Room 2");
+ sleep(1);
+};
+
+p3.code: {
+// Room 3
+ fprintf(stderr, "\n\nCat is in Room 3");
+ sleep(1);
+};
+
+p4.code: {
+// Room 4
+ fprintf(stderr, "\n\nCat is in Room 4");
+ sleep(1);
+};
+
+p5.code: {
+// Room 5
+ fprintf(stderr, "\n\nCat is in Room 5");
+ sleep(1);
+};
+
+(p1, c1, p2);
+(p2, c2, p3);
+(p3, c3, p1);
+(p1, c4, p4);
+(p4, c5, p5);
+(p5, c6, p1);
+(p2, c7, p4);
+(p4, c8, p2);
+
+
+MOUSE.PN:
+
+places: p6 p7 p8 p9 p10;
+
+transitions: m1 m2 m3 m4 m5 m6;
+
+// This function defines the places a mouse can go.
+
+p6.code: {
+// Room 1
+ fprintf(stderr, "\n\nMouse is in Room 1");
+ sleep(1);
+};
+
+p7.code: {
+// Room 2
+ fprintf(stderr, "\n\nMouse is in Room 2");
+ sleep(1);
+};
+
+p8.code: {
+// Room 3
+ fprintf(stderr, "\n\nMouse is in Room 3");
+ sleep(1);
+};
+
+p9.code: {
+// Room 4
+ fprintf(stderr, "\n\nMouse is in Room 4");
+ sleep(1);
+};
+
+p10.code: {
+// Room 5
+ fprintf(stderr, "\n\nMouse is in Room 5");
+ sleep(1);
+};
+
+(p6, m1, p8);
+(p8, m2, p7);
+(p7, m3, p6);
+(p6, m4, p10);
+(p10, m5, p9);
+(p9, m6, p6);
+
+
+CAT cat(p3:1); // defines one cat initialized in Room 3
+MOUSE mouse(p10:1); // defines one mouse initialized in Room 5
+
+
+
+global.constraints:
+
+// No room can contain a cat and mouse simultaneously
+
+cat.p1 + mouse.p6 <= 1;
+cat.p2 + mouse.p7 <= 1;
+cat.p3 + mouse.p8 <= 1;
+cat.p4 + mouse.p9 <= 1;
+cat.p5 + mouse.p10 <= 1;
\ No newline at end of file
Copied: examples-old/loop.sp (from rev 250, examples/loop.sp)
===================================================================
--- examples-old/loop.sp (rev 0)
+++ examples-old/loop.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,38 @@
+// This is an example illustrating conditional transitions and loops.
+
+
+
+process MLOOP;
+
+build: {<thread>};
+
+include: {
+ #include<stdio.h>
+ static int i = 0; // 'i' shared by threads in the same group; the 'static'
+ // keyword ensures that it is not visible to other threads
+};
+
+MLOOP.PN:
+
+places: p0 p1;
+
+transitions: t0 t1 t2;
+
+(p0, t0, p1);
+(p1, t1, p0).{i < 4}; // Transition takes place only if i < 4.
+(p1, t2).{i >= 4}; // exit via t2 if i is greater than 4.
+
+p0.code: {
+ fprintf(stderr, "\nState 0, i = %d", i);
+ fflush(0);
+ sleep(1);
+ i++;
+};
+
+p1.code: {
+ fprintf(stderr, "\nState 1, i = %d", i);
+ fflush(0);
+ sleep(1);
+};
+
+MLOOP pr1(p0:1);
Copied: examples-old/loop3.sp (from rev 250, examples/loop3.sp)
===================================================================
--- examples-old/loop3.sp (rev 0)
+++ examples-old/loop3.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,159 @@
+
+process SPR;
+
+build: {<supervisor>};
+
+include: {
+ #include<stdio.h>
+ int result, N; // these will be used as shared variable
+ int a[10]; // declares a shared array of 10 integers
+
+<main>
+
+ // <main> indicates that what follows is part of the main function of the
+ // supervisor.
+
+ N = 5;
+ result = 0;
+
+ /* The following function call will execute the code of the supervisor,
+ which in turn will start and execute the code of the specified processes
+ and/or threads. */
+
+ ___run_supervisor();
+
+ // The result of the program is verified:
+
+ printf("\nThe result is %d. The expected result was %d.\n", result, 3*N);
+
+ // A return instruction is ESSENTIAL when the code calls
+ // ___run_supervisor(). Otherwise, this function will be called again by
+ // the default instructions of the generated code.
+
+ return 0;
+};
+
+
+process LOOP_1;
+
+build: {<thread>};
+
+include: {
+ #include<stdio.h>
+ extern int result;
+ extern int N;
+ extern int a[];
+ static int i;
+ static int j;
+
+ // 'extern' indicates a variable defined in another C file of the project
+ // 'static' defines a variable invisible to the other C files of the project
+
+<main> // This indicates code for the main function of the thread
+
+ fprintf(stderr, "\nA LOOP_1 thread was started.");
+ fflush(0);
+ i = 0;
+
+};
+
+
+process LOOP_2;
+
+build: {<thread>};
+
+include: {
+ #include<stdio.h>
+ extern int result;
+ extern int N;
+ static int i;
+ static int j;
+
+ // 'extern' indicates a variable defined in another C file of the project
+ // 'static' defines a variable invisible to the other C files of the project
+
+<main> // This indicates code for the main function of the thread
+
+ fprintf(stderr, "\nA LOOP_2 thread was started.");
+ fflush(0);
+ i = 0;
+
+};
+
+
+
+SPR.PN:
+
+places: p0;
+
+transitions: t0;
+
+(p0, t0);
+
+
+
+
+LOOP_1.PN:
+
+places: p0 p1;
+
+transitions: t0 t1 t2;
+
+(p0, t0, p1);
+(p1, t1, p0).{i < N}; // Transition takes place only if i < N.
+(p1, t2).{i >= N}; // exit via t2 if i is greater than N.
+
+p0.code: {
+ fprintf(stderr, "\nLOOP_1: State 0, i = %d", i);
+ fflush(0);
+ sleep(1);
+ i++;
+};
+
+p1.code: {
+ j = result + 1;
+ fprintf(stderr, "\nLOOP_1: State 1, i = %d", i);
+ fflush(0);
+ sleep(1);
+ result = j;
+};
+
+
+
+LOOP_2.PN:
+
+places: p0 p1;
+
+transitions: t0 t1 t2;
+
+(p0, t0, p1);
+(p1, t1, p0).{i < N}; // Transition takes place only if i < N.
+(p1, t2).{i >= N}; // exit via t2 if i is greater than N.
+
+p0.code: {
+ fprintf(stderr, "\nLOOP_2: State 0, i = %d", i);
+ fflush(0);
+ sleep(1);
+ i++;
+};
+
+p1.code: {
+ j = result + 2;
+ fprintf(stderr, "\nLOOP_2: State 1, i = %d", i);
+ fflush(0);
+ sleep(1);
+ result = j;
+};
+
+
+
+
+
+LOOP_1 a(p0:1);
+LOOP_2 b(p0:1);
+SPR sp;
+
+
+global.constraints:
+
+a.p1 + b.p1 <= 1; // implement mutual exclusion
Copied: examples-old/reader.sp (from rev 250, examples/reader.sp)
===================================================================
--- examples-old/reader.sp (rev 0)
+++ examples-old/reader.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,124 @@
+// This is a reader/writer/inserter example
+
+process READER;
+build: {<thread>};
+
+process DELETER;
+build: {<thread>};
+
+process INSERTER;
+build: {<thread>};
+
+READER.PN:
+
+places: pv pc pd;
+
+transitions: tv tc td;
+
+// The main function for a thread/process defines a void* type pointer p___ initialized to zero.
+// This is useful when several copies of a thread run in parallel, so that each thread copy
+// has a known variable to allocate so that it can save its own data. Further, an initialization
+// function can be called if p___ = 0.
+
+pv.code: {
+//evaluate_data(&p___);
+ debugInfo("READER: Entering the evaluation block");
+ sleep(1);
+};
+
+pc.code: {
+//read_data(&p___);
+ debugInfo("READER: Entering the read block");
+ sleep(1);
+ debugInfo("READER: Exiting the read block");
+};
+
+pd.code: {
+//process_data(&p___);
+ debugInfo("READER: Entering the processing block");
+ sleep(1);
+};
+
+(pv, tv, pc);
+(pc, tc, pd);
+(pd, td, pv);
+
+
+DELETER.PN:
+
+places: pv pc pd;
+
+transitions: tv tc td;
+
+pv.code: {
+//d_evaluate_data(&p___);
+ debugInfo("DELETER: Entering the evaluation block");
+ sleep(1);
+
+};
+
+pc.code: {
+//delete_data(&p___);
+ debugInfo("DELETER: Entering the read block");
+ sleep(1);
+ debugInfo("DELETER: Exiting the read block");
+
+};
+
+pd.code: {
+//d_process_data(&p___);
+ debugInfo("DELETER: Entering the processing block");
+ sleep(1);
+
+};
+
+(pv, tv, pc);
+(pc, tc, pd);
+(pd, td, pv);
+
+
+INSERTER.PN:
+
+places: pv pc pd;
+
+transitions: tv tc td;
+
+pv.code: {
+//i_evaluate_data(&p___);
+ debugInfo("INSERTER: Entering the evaluation block");
+ sleep(1);
+};
+
+pc.code: {
+//insert_data(&p___);
+ debugInfo("INSERTER: Entering the read block");
+ sleep(1);
+ debugInfo("INSERTER: Exiting the read block");
+};
+
+pd.code: {
+//i_process_data(&p___);
+ debugInfo("INSERTER: Entering the processing block");
+ sleep(1);
+};
+
+(pv, tv, pc);
+(pc, tc, pd);
+(pd, td, pv);
+
+
+READER read(pv:5); // defines five reader processes starting in state pv
+INSERTER insert(pv:3);
+DELETER delete(pv:3);
+
+
+global.constraints:
+
+insert.pc <= 1;
+
+// delete.pc <= 1; // not necessary: see constraint below
+
+// The following should be read.pc + insert.pc + 6*delete.pc <= 6
+// However, the translator has a bug preventing it from recognizing multipliers
+
+read.pc + insert.pc + delete.pc + delete.pc + delete.pc + delete.pc + delete.pc + delete.pc<= 6; // 6 is max(reader.pc + inserter.pc)
Copied: examples-old/test.sp (from rev 250, examples/test.sp)
===================================================================
--- examples-old/test.sp (rev 0)
+++ examples-old/test.sp 2011-07-15 15:22:06 UTC (rev 251)
@@ -0,0 +1,23 @@
+// This is a test file created in order to check the functionality of the
+// pn translator.
+
+process TST;
+
+include: {
+ int i;
+};
+
+TST.PN:
+
+places: p0 p1 p2;
+
+transitions: t0 t1 t2;
+
+(p0, t0);
+(t2, p0);
+(p1, t1, p2, p0); // this is not a state machine;
+(p1, t1, p2, p0); // the code generator assumes state machines.
+(p2, t2, p1).{i == 3};
+
+TST testpn(p0:2,p1:1);
+
Copied: examples-old/test2.sp (from rev 250, examples/test2.sp)
===================================================================
--- examples-old/test2.sp ...
[truncated message content] |