/* Model of transaction server that can process */ /* several transactions in parallel. */ /* Transaction is a transit of a (money) value from */ /* a bill to another bill. */ /* Invariant of parallel computation: the sum of */ /* should not to vary all the time */ /* */ /* Class Trn_gen simulates a stream of transactions */ /* from an environment of computer system. */ /* Public class Program implements main program. */ /* Main program is started: */ /* java Program p1 p2 p3 p4 */ /* - p1 is the dimension of the database table */ /* - p2 is the initial value of every bill */ /* - p3 how many transaction should be processed */ /* - p4 num.of transactions processed in parallel */ /* */ /* Recommended parameters to start the trials: */ /* java 10 100 100 3 */ /*****************************************************/ /* Trida Trn_gen implementuje proud transakci z okoli */ /* Public trida Program implementuje hlavni program */ /* Hlavni program se startuje: */ /* java Program p1 p2 p3 p4 */ /* - p1 je rozmer (jedine) tabulky databaze */ /* - p2 je pocatecni hodnota na kazdem uctu */ /* - p3 je pocet zpracovavanych transakci */ /* - p4 je pocet paralelne provadenych transakci */ /* Doporucene startovani pro prvni seznameni: */ /* java 10 100 100 3 */ /*****************************************************/ class Trn_gen extends Thread { //thread private int n_row; // num of records in the table private int ini_value; // initial value of every account private Msg_port port; // port for requests private int n_trns; // num of processed transactions public Trn_gen (int par_n_row, int par_value, int par_n_trns, Msg_port par_port) { n_row = par_n_row; ini_value = par_value; n_trns = par_n_trns; port = par_port; } public void run () { for (int i=0; i