[Pvfs2-cvs] commit by kunkel in pvfs2/doc/design: state-machine.tex
CVS commit program
cvs at parl.clemson.edu
Wed May 23 16:49:11 EDT 2007
Update of /projects/cvsroot/pvfs2/doc/design
In directory parlweb1:/tmp/cvs-serv20193/doc/design
Added Files:
Tag: pvfs2-kunkel-tas-branch
state-machine.tex
Log Message:
Merge HEAD changes to TAS-branch.
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ state-machine.tex 2007-05-23 16:49:11.000000000 -0400
@@ -0,0 +1,108 @@
+
+\section{State Machine Code}
+
+Both the PVFS client and server use a state machine model to control
+execution. State machines are written in files with a .sm extention and
+are compiled into C data structures for further compilation and linking.
+
+A state machine consists of a set of states, with one state indicated as
+the first state. Each state includes a state action followed by a set of
+the possible transitions to other states. Each transtition includes the
+name of the next state and the return code that is used to select that
+transition.
+
+Alternatively a state can specify another "nested" state machine rather
+than a state action, in which case this new state machine is executed as
+a subroutine. Upon return, the nested state machine returns to the
+calling state machine. A state can also specify that multiple instances
+of a state machine will be executed concurrently. When all of the
+concurrent state machines have returned the caller continues.
+
+Transitions can specify another state in the same machine, or to return
+from a nested state machine, or to terminate the current state machine.
+
+The following is a synopsis of the state machine language, showing the
+various options by way of example:
+
+\begin{verbatim}
+/* beginning of .sm file */
+
+/* code at the top of the file is plain C code. */
+/* state actions must be declared here before the state machine */
+
+static PINT_sm_action state_action_1 (
+ struct PINT_smcb *smcb, job_status_s *js_p);
+static PINT_sm_action state_action_3 (
+ struct PINT_smcb *smcb, job_status_s *js_p);
+static PINT_sm_action state_action_4 (
+ struct PINT_smcb *smcb, job_status_s *js_p);
+
+/* helper functions and other declarations go here too */
+
+#define RETVAL 1
+
+%%
+
+/* after the double percent goes the machine declaration */
+
+machine my_machine_sm (
+ state_1,
+ state_2,
+ state_3)
+{
+ state state_1
+ {
+ run state_action_1;
+ success => state_2; /* success is return value 0 */
+ default => state_4;
+ }
+
+ state state_2
+ {
+ jump a_nested_state_machine_sm;
+ RETVAL => state_3;
+ }
+
+ state state_3
+ {
+ pjmp state_action_3
+ {
+ /* values here are set up in state_action_3 */
+ 4 => parallel_state_machine_1;
+ 3 => parallel_state_machine_2;
+ RETVAL => parallel_state_machine_3;
+ }
+ default => state_4;
+ }
+
+ state state_4
+ {
+ /* this state action cleans up after the pjmp */
+ run state_action_4;
+ default => terminate;
+ }
+}
+
+%%
+
+/* after the second double percent all code is in plain C */
+/* here we implement all of the state actions */
+
+static PINT_sm_action state_action_1 (
+ struct PINT_smcb *smcb, job_status_s *js_p)
+{
+}
+
+static PINT_sm_action state_action_3 (
+ struct PINT_smcb *smcb, job_status_s *js_p)
+{
+}
+
+static PINT_sm_action state_action_4 (
+ struct PINT_smcb *smcb, job_status_s *js_p)
+{
+}
+
+\end{verbatim}
+
+
More information about the Pvfs2-cvs
mailing list