Changeset 8659435
- Timestamp:
- Mar 1, 2026, 5:19:18 PM (12 hours ago)
- Branches:
- master
- Children:
- 8086004
- Parents:
- acb89d74
- File:
-
- 1 edited
-
doc/uC++toCFA/uC++toCFA.tex (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/uC++toCFA/uC++toCFA.tex
racb89d74 r8659435 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Mon Nov 17 11:14:48 202514 %% Update Count : 6 67713 %% Last Modified On : Fri Feb 20 11:19:31 2026 14 %% Update Count : 6717 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 194 194 195 195 The @choose@ statement provides an implicit @break@ after the @case@ clause for safety. 196 It is possible to @ break default@ in a @case@ clause to transfer to common code inthe @default@ clause.197 \begin{cquote} 198 \begin{tabular}{@{}l|l@{}} 199 \begin{ uC++}196 It is possible to @fallthrough@ label in a @case@ clause to transfer to common code or the @default@ clause. 197 \begin{cquote} 198 \begin{tabular}{@{}l|l@{}} 199 \begin{cfa} 200 200 switch ( i ) { 201 case 1: ... @break@; // explicit break 202 case 2: ... @break@; // explicit break 201 case 3: ... @fallthrough common@; 202 case 2: if ( ... ) @fallthrough@; 203 case 1: 204 common: ... ; // implicit fall through 203 205 default: ... ; 204 206 } 205 \end{ uC++}207 \end{cfa} 206 208 & 207 209 \begin{cfa} 208 210 choose ( i ) { 209 case 1: ... ; // implicit break 210 case 2: ... ; // implicit break 211 case 3: ... @fallthrough common@; // labelled explicit fallthrough 212 case 2: if ( ... ) @fallthrough@; // conditional explicit fallthrough 213 case 1: 214 common: ... ; // implicit break 211 215 default: ... ; 212 216 } … … 250 254 for ( i; @5@ ~ @15@ ~ @2@ ) { ... } // 5 to 14 by 2 251 255 for ( i; -2 ~@=@ 10 ~ 3 ) { ... } // -2 to 10 by 3 252 for ( i; -3 @-@~ 10 ) { ... } // not 10 -~= -3, 10 to -2 by -1253 for ( i; 0 @-@~@=@ 10 ) { ... } // not 10 -~= 0, 10 to 0 by -1256 for ( i; -3 @-@~ 10 ) { ... } // 10 to -2 by -1, not 10 -~= -3 257 for ( i; 0 @-@~@=@ 10 ) { ... } // 10 to 0 by -1, not 10 -~= 0 254 258 \end{cfa} 255 259 \end{tabular} … … 908 912 public: 909 913 }; 914 T t; 915 uProcessor p[3]; 910 916 \end{uC++} 911 917 & … … 917 923 }; 918 924 void main( @T & t@ ) { 919 ... @resumeAt( partner, ExceptionInst( E, ... ) @ );925 ... @resumeAt( partner, ExceptionInst( E, ... ) )@; 920 926 ... @active_thread();@ ... 921 927 } 922 \end{cfa} 923 \\ 924 \ multicolumn{2}{@{}l@{}}{\lstinline{T t; // start thread in main routine}}928 T t; // create thread object and start thread in main 929 processor p[3]; // 4 kernel threads including program main 930 \end{cfa} 925 931 \end{tabular} 926 932 \end{cquote} … … 1009 1015 } 1010 1016 }; 1011 enum { N = 3 }; 1012 Barrier b{ N }; 1017 Barrier b{ 3 }; 1013 1018 \end{uC++} 1014 1019 & … … 1034 1039 } 1035 1040 } 1036 enum { N = 3 }; 1037 Barrier b{ N }; 1041 Barrier b{ 3 }; 1038 1042 \end{cfa} 1039 1043 \end{tabular} … … 1178 1182 1179 1183 1180 {\lstset{tabsize= 3}1184 {\lstset{tabsize=4} 1181 1185 \setlength{\tabcolsep}{5pt} 1182 1186 \begin{tabular}{@{}l|ll@{}} … … 1186 1190 @Future_ISM@<double> fd; 1187 1191 struct Msg { int i, j; }; @Future_ISM@<Msg> fm; 1188 struct Stop {}; @Future_ISM@<Stop> fs;1189 1192 struct Cont {}; @Future_ISM@<Cont> fc; 1193 _Exception Stop {}; 1190 1194 1191 1195 _Task Worker { 1192 1196 void main() { 1193 1194 for ( ;; ) {1195 _Select( fi ) { cout << fi() << endl; fi.reset(); }1196 and _Select( fd ) { cout << fd() << endl; fd.reset(); }1197 and _Select( fm ) {1198 cout << fm().i << " " << fm().j << endl; fm.reset();1199 } or _Select( fs ) { cout << "stop" << endl; break;}1200 fc.delivery( (Cont){} );// synchronize1201 }1202 }1203 1197 try { 1198 for ( ;; ) { 1199 _Select( fi ) { cout << fi() << endl; fi.reset(); } 1200 and _Select( fd ) { cout << fd() << endl; fd.reset(); } 1201 and _Select( fm ) { 1202 cout << fm().i << " " << fm().j << endl; fm.reset(); 1203 } 1204 fc( (Cont){} ); // synchronize 1205 } 1206 } catch( Stop & ) { cout << "stop" << endl;} 1207 } 1204 1208 }; 1205 1209 int main() { 1206 1210 Worker worker; 1207 1211 for ( int i = 0; i < 10; i += 1 ) { 1208 fi( i ); fd( i + 2.5 ); fm( (Msg){ i, 2 } ); // fulfil1212 fi( i ); fd( i + 2.5 ); fm( (Msg){ i, 2 } ); // fulfil 1209 1213 fc(); fc.reset(); // synchronize 1210 1214 } 1211 f s( (Stop){} );1215 fi( new Stop{} ); // trigger exception 1212 1216 } // wait for worker to terminate 1213 1217 \end{uC++} … … 1215 1219 \begin{cfa} 1216 1220 #include <future.hfa> 1217 @future_rc@( int) fi;1218 @future_rc@( double) fd;1219 struct Msg { int i, j; }; @future_rc@( Msg) fm;1220 struct Stop {}; @future_rc@(Stop) fs;1221 struct Cont {}; @future_rc@(Cont) fc;1222 ExceptionDecl( Break ); 1221 @future_rc@( int ) fi; 1222 @future_rc@( double ) fd; 1223 struct Msg { int i, j; }; @future_rc@( Msg ) fm; 1224 struct Cont {}; @future_rc@( Cont ) fc; 1225 ExceptionDecl( Stop ); 1226 1223 1227 thread Worker {}; 1224 1228 void main( Worker & ) { … … 1227 1231 waituntil( fi ) { sout | fi(); reset( fi ); } 1228 1232 and waituntil( fd ) { sout | fd(); reset( fd ); } 1229 and waituntil( fm ) { sout | fm().i | fm().j; reset( fm ); } 1230 or waituntil( fs ) { sout | "stop"; 1231 throw ExceptionInst( Break ); 1233 and waituntil( fm ) { 1234 sout | fm().i | fm().j; reset( fm ); 1232 1235 } 1233 1236 fc( (Cont){} ); // synchronize 1234 1237 } 1235 } catch( Break * ) {} 1236 } 1238 } catch( Stop * ) { sout | "stop"; } 1239 } 1240 1237 1241 int main() { 1238 1242 Worker worker; 1239 1243 for ( i; 10 ) { 1240 fi( i ); fd( i + 2.5 ); fm( (Msg){ i, 2 } ); // fulfil1244 fi( i ); fd( i + 2.5 ); fm( (Msg){ i, 2 } ); // fulfil 1241 1245 fc(); reset( fc ); // synchronize 1242 1246 } 1243 f s( (Stop){});1247 fi( ExceptionPtr( ExceptionInst( Stop ) ) ); 1244 1248 } // wait for worker to terminate 1245 1249 \end{cfa}
Note:
See TracChangeset
for help on using the changeset viewer.