55 */
66
77
8- target TypeScript {
8+ target TypeScript {
99 fast: true
1010};
1111
1212import BenchmarkRunner from "../BenchmarkRunner.lf";
1313
14-
1514reactor Philosopher(count:number(10000)) {
1615
1716 input start: boolean;
@@ -48,7 +47,7 @@ reactor Philosopher(count:number(10000)) {
4847}
4948
5049
51- reactor Arbitrator(num_philosophers :number(20)) {
50+ reactor Arbitrator(numPhilosophers :number(20)) {
5251 preamble {=
5352 enum Reply {
5453 INVALID = 0,
@@ -60,11 +59,11 @@ reactor Arbitrator(num_philosophers:number(20)) {
6059 input start: boolean;
6160 output allFinished: boolean;
6261
63- input[num_philosophers ] finished: boolean;
64- input[num_philosophers ] done: boolean;
65- input[num_philosophers ] hungry: boolean;
66- output[num_philosophers ] eat: boolean;
67- output[num_philosophers ] denied: boolean;
62+ input[numPhilosophers ] finished: boolean;
63+ input[numPhilosophers ] done: boolean;
64+ input[numPhilosophers ] hungry: boolean;
65+ output[numPhilosophers ] eat: boolean;
66+ output[numPhilosophers ] denied: boolean;
6867
6968 state forks: {=Array<boolean>=}({= [] =});
7069 state replies: {=Array<number>=}({= [] =});
@@ -75,8 +74,8 @@ reactor Arbitrator(num_philosophers:number(20)) {
7574 logical action sendReplies;
7675
7776 reaction(startup) {=
78- forks.length = num_philosophers ;
79- replies.length = num_philosophers ;
77+ forks.length = numPhilosophers ;
78+ replies.length = numPhilosophers ;
8079 =}
8180
8281 reaction(start) {=
@@ -88,7 +87,7 @@ reactor Arbitrator(num_philosophers:number(20)) {
8887 =}
8988
9089 reaction(sendReplies) -> eat, denied {=
91- for(let i = 0; i < num_philosophers ; i++) {
90+ for(let i = 0; i < numPhilosophers ; i++) {
9291 if (replies[i] == Reply.EAT) {
9392 eat[i] = true;
9493 } else if (replies[i] == Reply.DENIED) {
@@ -99,42 +98,42 @@ reactor Arbitrator(num_philosophers:number(20)) {
9998 =}
10099
101100 reaction (done) {=
102- for(let i = 0; i < num_philosophers ; i++){
101+ for(let i = 0; i < numPhilosophers ; i++){
103102 if (done[i] !== undefined) {
104103 forks[i] = false;
105- forks[(i + 1) % num_philosophers ] = false;
104+ forks[(i + 1) % numPhilosophers ] = false;
106105 }
107106 }
108107 =}
109108
110109 reaction(hungry) -> sendReplies {=
111- for(let i = 0; i < num_philosophers ; i++) {
112- const j= (i + arbitration_id) % num_philosophers ;
110+ for(let i = 0; i < numPhilosophers ; i++) {
111+ const j= (i + arbitration_id) % numPhilosophers ;
113112
114113 if(hungry[j] !== undefined) {
115114 const left = j;
116- const right = (j + 1) % num_philosophers ;
115+ const right = (j + 1) % numPhilosophers ;
117116
118117 if(forks[left] || forks[right]) {
119118 replies[j] = Reply.DENIED;
120119 ++numRetries;
121120 } else {
122121 forks[j] = true;
123- forks[(j + 1) % num_philosophers ] = true;
122+ forks[(j + 1) % numPhilosophers ] = true;
124123 replies[j] = Reply.EAT;
125124 }
126125 }
127126 }
128- arbitration_id = (arbitration_id + 1) % num_philosophers ;
127+ arbitration_id = (arbitration_id + 1) % numPhilosophers ;
129128 actions.sendReplies.schedule(0, null);
130129 =}
131130
132131 reaction (finished) -> allFinished {=
133- // i < finished_width ... finished_width = num_philosophers in this code
134- for(let i = 0; i < num_philosophers ; i++) {
132+ // i < finished_width ... finished_width = numPhilosophers in this code
133+ for(let i = 0; i < numPhilosophers ; i++) {
135134 if(finished[i] !== undefined) {
136135 ++numFinishedPhilosophers;
137- if(num_philosophers == numFinishedPhilosophers) {
136+ if(numPhilosophers == numFinishedPhilosophers) {
138137 console.log("Arbitrator: All philosophers are sated. Number of denials to philosophers: " + numRetries + "\n");
139138 allFinished = true;
140139 }
@@ -144,11 +143,11 @@ reactor Arbitrator(num_philosophers:number(20)) {
144143}
145144
146145
147- main reactor Philosophers (numIterations:number(12), num_philosophers :number(20), count:number(100)){
146+ main reactor Philosophers (numIterations:number(12), numPhilosophers :number(20), count:number(100)){
148147
149- arbitrator = new Arbitrator(num_philosophers = num_philosophers );
150- philosophers = new[num_philosophers ] Philosopher(count=count);
151- runner = new BenchmarkRunner(num_iterations = numIterations);
148+ arbitrator = new Arbitrator(numPhilosophers = numPhilosophers );
149+ philosophers = new[numPhilosophers ] Philosopher(count=count);
150+ runner = new BenchmarkRunner(numIterations = numIterations);
152151
153152 reaction (startup) {=
154153 console.log("Start Philosophers LF Benchmark!");
0 commit comments