/* * This example describes a parallel server which can handle at * maximum N requests simultaneously. Thus, when possible, for a * -request- message (received from the environment) a client * is created. The server keeps in the -i- variable the number * of running clients. Client processes are quite simple: once * created, they work, and when finished they send a -done- message * back to the server. In addition, these signals are delayed * through the signalroute cs. * */ system server_test; const N = 2; signal done(pid); signal request(); signalroute es(1) from env to server with request; signalroute cs(1) #delay[1,2] from client to server with done; process server(1); var i integer; var x pid; state idle #start ; deadline lazy; provided (i < N); input request(); x := fork client(self); task i := (i + 1); nextstate idle; input done(x); task i := (i - 1); nextstate idle; endstate; endprocess; process client(0); fpar parent pid; state init #start ; deadline lazy; informal "work"; output done(self) via {cs}0 to parent; stop; endstate; endprocess; endsystem;