Changes in / [212c421e:f22b7aef]
- Location:
- src
- Files:
-
- 1 deleted
- 19 edited
-
Concurrency/Keywords.cc (modified) (7 diffs)
-
Parser/ParseNode.h (modified) (1 diff)
-
Parser/StatementNode.cc (modified) (2 diffs)
-
Parser/parser.yy (modified) (5 diffs)
-
SynTree/Mutator.cc (modified) (61 diffs)
-
SynTree/Mutator.h (modified) (1 diff)
-
SynTree/Statement.cc (modified) (1 diff)
-
SynTree/Statement.h (modified) (2 diffs)
-
SynTree/SynTree.h (modified) (1 diff)
-
SynTree/Visitor.cc (modified) (1 diff)
-
SynTree/Visitor.h (modified) (1 diff)
-
libcfa/concurrency/invoke.h (modified) (3 diffs)
-
libcfa/concurrency/kernel.c (modified) (4 diffs)
-
libcfa/concurrency/monitor (modified) (4 diffs)
-
libcfa/concurrency/monitor.c (modified) (19 diffs)
-
libcfa/concurrency/preemption.c (modified) (2 diffs)
-
tests/preempt_longrun/stack.c (modified) (1 diff)
-
tests/sched-ext.c (deleted)
-
tests/sched-int-disjoint.c (modified) (2 diffs)
-
tests/sched-int-wait.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
r212c421e rf22b7aef 201 201 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); 202 202 void validate( DeclarationWithType * ); 203 void addStatments( FunctionDecl* func,CompoundStmt *, const std::list<DeclarationWithType * > &);203 void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &); 204 204 205 205 static void implement( std::list< Declaration * > & translationUnit ) { … … 211 211 StructDecl* monitor_decl = nullptr; 212 212 StructDecl* guard_decl = nullptr; 213 214 static std::unique_ptr< Type > generic_func;215 213 }; 216 217 std::unique_ptr< Type > MutexKeyword::generic_func = std::unique_ptr< Type >(218 new FunctionType(219 noQualifiers,220 true221 )222 );223 214 224 215 //----------------------------------------------------------------------------- … … 404 395 // Mutex keyword implementation 405 396 //============================================================================================= 406 407 397 void MutexKeyword::visit(FunctionDecl* decl) { 408 398 Visitor::visit(decl); … … 421 411 if( !guard_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl ); 422 412 423 addStatments( decl,body, mutexArgs );413 addStatments( body, mutexArgs ); 424 414 } 425 415 … … 468 458 } 469 459 470 void MutexKeyword::addStatments( FunctionDecl* func,CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {460 void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) { 471 461 ObjectDecl * monitors = new ObjectDecl( 472 462 "__monitors", … … 499 489 ); 500 490 501 assert(generic_func);502 503 491 //in reverse order : 504 // monitor_guard_t __guard = { __monitors, # , func};492 // monitor_guard_t __guard = { __monitors, # }; 505 493 body->push_front( 506 494 new DeclStmt( noLabels, new ObjectDecl( … … 516 504 { 517 505 new SingleInit( new VariableExpr( monitors ) ), 518 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ), 519 new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) ) 506 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 520 507 }, 521 508 noDesignators, -
src/Parser/ParseNode.h
r212c421e rf22b7aef 414 414 Statement * build_compound( StatementNode * first ); 415 415 Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr ); 416 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when );417 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing );418 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when );419 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when );420 416 421 417 //############################################################################## -
src/Parser/StatementNode.cc
r212c421e rf22b7aef 93 93 elseb = branches.front(); 94 94 } // if 95 95 96 96 std::list< Statement * > init; 97 97 if ( ctl->init != 0 ) { … … 207 207 } 208 208 209 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when ) {210 auto node = new WaitForStmt();211 212 WaitForStmt::Target target;213 target.function = maybeBuild<Expression>( targetExpr );214 buildMoveList< Expression >( targetExpr, target.arguments );215 delete targetExpr;216 217 node->clauses.push_back( WaitForStmt::Clause{218 target,219 maybeMoveBuild<Statement >( stmt ),220 maybeMoveBuild<Expression>( when )221 });222 223 return node;224 }225 226 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) {227 WaitForStmt::Target target;228 229 target.function = maybeBuild<Expression>( targetExpr );230 buildMoveList< Expression >( targetExpr, target.arguments );231 delete targetExpr;232 233 node->clauses.push_back( WaitForStmt::Clause{234 std::move( target ),235 maybeMoveBuild<Statement >( stmt ),236 maybeMoveBuild<Expression>( when )237 });238 239 return node;240 }241 242 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when ) {243 auto node = new WaitForStmt();244 245 if( timeout ) {246 node->timeout.time = maybeMoveBuild<Expression>( timeout );247 node->timeout.statement = maybeMoveBuild<Statement >( stmt );248 node->timeout.condition = maybeMoveBuild<Expression>( when );249 }250 else {251 node->orelse.statement = maybeMoveBuild<Statement >( stmt );252 node->orelse.condition = maybeMoveBuild<Expression>( when );253 }254 255 return node;256 }257 258 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when ) {259 auto node = new WaitForStmt();260 261 node->timeout.time = maybeMoveBuild<Expression>( timeout );262 node->timeout.statement = maybeMoveBuild<Statement >( stmt );263 node->timeout.condition = maybeMoveBuild<Expression>( when );264 265 node->orelse.statement = maybeMoveBuild<Statement >( else_stmt );266 node->orelse.condition = maybeMoveBuild<Expression>( else_when );267 268 return node;269 }270 271 // WaitForStmt::Target build_waitfor( const std::string * name, ExpressionNode * arguments ) {272 // return WaitForStmt::Clause{273 274 // };275 // }276 277 209 Statement *build_compound( StatementNode *first ) { 278 210 CompoundStmt *cs = new CompoundStmt( noLabels ); -
src/Parser/parser.yy
r212c421e rf22b7aef 97 97 DeclarationNode::TypeClass tclass; 98 98 StatementNode * sn; 99 WaitForStmt * wfs;100 99 ConstantExpr * constant; 101 100 IfCtl * ifctl; … … 188 187 %type<flag> asm_volatile_opt 189 188 %type<en> handler_predicate_opt 190 %type<en> when_clause_opt timeout191 189 192 190 // statements … … 194 192 %type<sn> iteration_statement jump_statement 195 193 %type<sn> with_statement exception_statement asm_statement 196 %type<sn> w aitfor_statement194 %type<sn> when_clause_opt waitfor_statement waitfor_clause waitfor timeout 197 195 %type<sn> fall_through_opt fall_through 198 196 %type<sn> statement statement_list … … 204 202 %type<sn> handler_clause finally_clause 205 203 %type<catch_kind> handler_key 206 %type<wfs> waitfor_clause207 %type<en> waitfor208 204 209 205 // declarations … … 983 979 when_clause_opt: 984 980 // empty 985 { $$ = nullptr; } 981 { $$ = nullptr; } // FIX ME 986 982 | WHEN '(' comma_expression ')' 987 { $$ = $3; }983 { $$ = nullptr; } // FIX ME 988 984 ; 989 985 990 986 waitfor: 991 987 WAITFOR '(' identifier ')' 992 { 993 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 994 delete $3; 995 } 988 { $$ = nullptr; } // FIX ME 996 989 | WAITFOR '(' identifier ',' argument_expression_list ')' 997 { 998 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 999 $$->set_last( $5 ); 1000 delete $3; 1001 } 990 { $$ = nullptr; } // FIX ME 1002 991 ; 1003 992 1004 993 timeout: 1005 994 TIMEOUT '(' comma_expression ')' 1006 { $$ = $3; }995 { $$ = nullptr; } // FIX ME 1007 996 ; 1008 997 1009 998 waitfor_clause: 1010 999 when_clause_opt waitfor statement %prec THEN 1011 { $$ = build_waitfor( $2, $3, $1 ); }1000 { $$ = nullptr; } // FIX ME 1012 1001 | when_clause_opt waitfor statement WOR waitfor_clause 1013 { $$ = build_waitfor( $2, $3, $1, $5 ); }1002 { $$ = nullptr; } // FIX ME 1014 1003 | when_clause_opt timeout statement %prec THEN 1015 { $$ = build_waitfor_timeout( $2, $3, $1 ); }1004 { $$ = nullptr; } // FIX ME 1016 1005 | when_clause_opt ELSE statement 1017 { $$ = build_waitfor_timeout( nullptr, $3, $1 ); }1006 { $$ = nullptr; } // FIX ME 1018 1007 | when_clause_opt timeout statement WOR when_clause_opt ELSE statement 1019 { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); }1008 { $$ = nullptr; } // FIX ME 1020 1009 ; 1021 1010 1022 1011 waitfor_statement: 1023 1012 when_clause_opt waitfor statement %prec THEN 1024 { $$ = n ew StatementNode( build_waitfor( $2, $3, $1 ) ); }1013 { $$ = nullptr; } // FIX ME 1025 1014 | when_clause_opt waitfor statement WOR waitfor_clause 1026 { $$ = n ew StatementNode( build_waitfor( $2, $3, $1, $5 ) ); }1015 { $$ = nullptr; } // FIX ME 1027 1016 ; 1028 1017 -
src/SynTree/Mutator.cc
r212c421e rf22b7aef 32 32 Mutator::~Mutator() {} 33 33 34 DeclarationWithType * Mutator::mutate( ObjectDecl *objectDecl ) {34 DeclarationWithType *Mutator::mutate( ObjectDecl *objectDecl ) { 35 35 objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) ); 36 36 objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) ); … … 39 39 } 40 40 41 DeclarationWithType * Mutator::mutate( FunctionDecl *functionDecl ) {41 DeclarationWithType *Mutator::mutate( FunctionDecl *functionDecl ) { 42 42 functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) ); 43 43 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) ); … … 45 45 } 46 46 47 Declaration * Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {47 Declaration *Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) { 48 48 mutateAll( aggregateDecl->get_parameters(), *this ); 49 49 mutateAll( aggregateDecl->get_members(), *this ); … … 51 51 } 52 52 53 Declaration * Mutator::mutate( StructDecl *aggregateDecl ) {53 Declaration *Mutator::mutate( StructDecl *aggregateDecl ) { 54 54 handleAggregateDecl( aggregateDecl ); 55 55 return aggregateDecl; 56 56 } 57 57 58 Declaration * Mutator::mutate( UnionDecl *aggregateDecl ) {58 Declaration *Mutator::mutate( UnionDecl *aggregateDecl ) { 59 59 handleAggregateDecl( aggregateDecl ); 60 60 return aggregateDecl; 61 61 } 62 62 63 Declaration * Mutator::mutate( EnumDecl *aggregateDecl ) {63 Declaration *Mutator::mutate( EnumDecl *aggregateDecl ) { 64 64 handleAggregateDecl( aggregateDecl ); 65 65 return aggregateDecl; 66 66 } 67 67 68 Declaration * Mutator::mutate( TraitDecl *aggregateDecl ) {68 Declaration *Mutator::mutate( TraitDecl *aggregateDecl ) { 69 69 handleAggregateDecl( aggregateDecl ); 70 70 return aggregateDecl; 71 71 } 72 72 73 Declaration * Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {73 Declaration *Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) { 74 74 mutateAll( typeDecl->get_parameters(), *this ); 75 75 mutateAll( typeDecl->get_assertions(), *this ); … … 78 78 } 79 79 80 TypeDecl * Mutator::mutate( TypeDecl *typeDecl ) {80 TypeDecl *Mutator::mutate( TypeDecl *typeDecl ) { 81 81 handleNamedTypeDecl( typeDecl ); 82 82 typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) ); … … 84 84 } 85 85 86 Declaration * Mutator::mutate( TypedefDecl *typeDecl ) {86 Declaration *Mutator::mutate( TypedefDecl *typeDecl ) { 87 87 handleNamedTypeDecl( typeDecl ); 88 88 return typeDecl; 89 89 } 90 90 91 AsmDecl * Mutator::mutate( AsmDecl *asmDecl ) {91 AsmDecl *Mutator::mutate( AsmDecl *asmDecl ) { 92 92 asmDecl->set_stmt( maybeMutate( asmDecl->get_stmt(), *this ) ); 93 93 return asmDecl; … … 95 95 96 96 97 CompoundStmt * Mutator::mutate( CompoundStmt *compoundStmt ) {97 CompoundStmt *Mutator::mutate( CompoundStmt *compoundStmt ) { 98 98 mutateAll( compoundStmt->get_kids(), *this ); 99 99 return compoundStmt; 100 100 } 101 101 102 Statement * Mutator::mutate( ExprStmt *exprStmt ) {102 Statement *Mutator::mutate( ExprStmt *exprStmt ) { 103 103 exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) ); 104 104 return exprStmt; 105 105 } 106 106 107 Statement * Mutator::mutate( AsmStmt *asmStmt ) {107 Statement *Mutator::mutate( AsmStmt *asmStmt ) { 108 108 asmStmt->set_instruction( maybeMutate( asmStmt->get_instruction(), *this ) ); 109 109 mutateAll( asmStmt->get_output(), *this ); … … 113 113 } 114 114 115 Statement * Mutator::mutate( IfStmt *ifStmt ) {115 Statement *Mutator::mutate( IfStmt *ifStmt ) { 116 116 mutateAll( ifStmt->get_initialization(), *this ); 117 117 ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) ); … … 121 121 } 122 122 123 Statement * Mutator::mutate( WhileStmt *whileStmt ) {123 Statement *Mutator::mutate( WhileStmt *whileStmt ) { 124 124 whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) ); 125 125 whileStmt->set_body( maybeMutate( whileStmt->get_body(), *this ) ); … … 127 127 } 128 128 129 Statement * Mutator::mutate( ForStmt *forStmt ) {129 Statement *Mutator::mutate( ForStmt *forStmt ) { 130 130 mutateAll( forStmt->get_initialization(), *this ); 131 131 forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) ); … … 135 135 } 136 136 137 Statement * Mutator::mutate( SwitchStmt *switchStmt ) {137 Statement *Mutator::mutate( SwitchStmt *switchStmt ) { 138 138 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 139 139 mutateAll( switchStmt->get_statements(), *this ); … … 141 141 } 142 142 143 Statement * Mutator::mutate( CaseStmt *caseStmt ) {143 Statement *Mutator::mutate( CaseStmt *caseStmt ) { 144 144 caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) ); 145 145 mutateAll (caseStmt->get_statements(), *this ); … … 148 148 } 149 149 150 Statement * Mutator::mutate( BranchStmt *branchStmt ) {150 Statement *Mutator::mutate( BranchStmt *branchStmt ) { 151 151 return branchStmt; 152 152 } 153 153 154 Statement * Mutator::mutate( ReturnStmt *returnStmt ) {154 Statement *Mutator::mutate( ReturnStmt *returnStmt ) { 155 155 returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) ); 156 156 return returnStmt; 157 157 } 158 158 159 Statement * Mutator::mutate( ThrowStmt *throwStmt ) {159 Statement *Mutator::mutate( ThrowStmt *throwStmt ) { 160 160 throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) ); 161 161 throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) ); … … 163 163 } 164 164 165 Statement * Mutator::mutate( TryStmt *tryStmt ) {165 Statement *Mutator::mutate( TryStmt *tryStmt ) { 166 166 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); 167 167 mutateAll( tryStmt->get_catchers(), *this ); … … 170 170 } 171 171 172 Statement * Mutator::mutate( CatchStmt *catchStmt ) {172 Statement *Mutator::mutate( CatchStmt *catchStmt ) { 173 173 catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) ); 174 174 catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) ); … … 177 177 } 178 178 179 Statement * Mutator::mutate( FinallyStmt *finalStmt ) {179 Statement *Mutator::mutate( FinallyStmt *finalStmt ) { 180 180 finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) ); 181 181 return finalStmt; 182 182 } 183 183 184 Statement * Mutator::mutate( WaitForStmt *waitforStmt ) { 185 for( auto & clause : waitforStmt->clauses ) { 186 clause.target.function = maybeMutate( clause.target.function, *this ); 187 mutateAll( clause.target.arguments, *this ); 188 189 clause.statement = maybeMutate( clause.statement, *this ); 190 clause.condition = maybeMutate( clause.condition, *this ); 191 } 192 193 waitforStmt->timeout.time = maybeMutate( waitforStmt->timeout.time, *this ); 194 waitforStmt->timeout.statement = maybeMutate( waitforStmt->timeout.statement, *this ); 195 waitforStmt->timeout.condition = maybeMutate( waitforStmt->timeout.condition, *this ); 196 waitforStmt->orelse.statement = maybeMutate( waitforStmt->orelse.statement, *this ); 197 waitforStmt->orelse.condition = maybeMutate( waitforStmt->orelse.condition, *this ); 198 199 return waitforStmt; 200 } 201 202 NullStmt * Mutator::mutate( NullStmt *nullStmt ) { 184 NullStmt *Mutator::mutate( NullStmt *nullStmt ) { 203 185 return nullStmt; 204 186 } 205 187 206 Statement * Mutator::mutate( DeclStmt *declStmt ) {188 Statement *Mutator::mutate( DeclStmt *declStmt ) { 207 189 declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) ); 208 190 return declStmt; 209 191 } 210 192 211 Statement * Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {193 Statement *Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) { 212 194 impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) ); 213 195 return impCtorDtorStmt; … … 215 197 216 198 217 Expression * Mutator::mutate( ApplicationExpr *applicationExpr ) {199 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) { 218 200 applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) ); 219 201 applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) ); … … 223 205 } 224 206 225 Expression * Mutator::mutate( UntypedExpr *untypedExpr ) {207 Expression *Mutator::mutate( UntypedExpr *untypedExpr ) { 226 208 untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) ); 227 209 untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) ); … … 230 212 } 231 213 232 Expression * Mutator::mutate( NameExpr *nameExpr ) {214 Expression *Mutator::mutate( NameExpr *nameExpr ) { 233 215 nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) ); 234 216 nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) ); … … 236 218 } 237 219 238 Expression * Mutator::mutate( AddressExpr *addressExpr ) {220 Expression *Mutator::mutate( AddressExpr *addressExpr ) { 239 221 addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) ); 240 222 addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) ); … … 243 225 } 244 226 245 Expression * Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {227 Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) { 246 228 labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) ); 247 229 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) ); … … 250 232 } 251 233 252 Expression * Mutator::mutate( CastExpr *castExpr ) {234 Expression *Mutator::mutate( CastExpr *castExpr ) { 253 235 castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) ); 254 236 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); … … 257 239 } 258 240 259 Expression * Mutator::mutate( VirtualCastExpr *castExpr ) {241 Expression *Mutator::mutate( VirtualCastExpr *castExpr ) { 260 242 castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) ); 261 243 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); … … 264 246 } 265 247 266 Expression * Mutator::mutate( UntypedMemberExpr *memberExpr ) {248 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) { 267 249 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 268 250 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); … … 272 254 } 273 255 274 Expression * Mutator::mutate( MemberExpr *memberExpr ) {256 Expression *Mutator::mutate( MemberExpr *memberExpr ) { 275 257 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 276 258 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); … … 279 261 } 280 262 281 Expression * Mutator::mutate( VariableExpr *variableExpr ) {263 Expression *Mutator::mutate( VariableExpr *variableExpr ) { 282 264 variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) ); 283 265 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) ); … … 285 267 } 286 268 287 Expression * Mutator::mutate( ConstantExpr *constantExpr ) {269 Expression *Mutator::mutate( ConstantExpr *constantExpr ) { 288 270 constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) ); 289 271 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) ); … … 292 274 } 293 275 294 Expression * Mutator::mutate( SizeofExpr *sizeofExpr ) {276 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) { 295 277 sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) ); 296 278 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) ); … … 303 285 } 304 286 305 Expression * Mutator::mutate( AlignofExpr *alignofExpr ) {287 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) { 306 288 alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) ); 307 289 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) ); … … 314 296 } 315 297 316 Expression * Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {298 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) { 317 299 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 318 300 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); … … 321 303 } 322 304 323 Expression * Mutator::mutate( OffsetofExpr *offsetofExpr ) {305 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) { 324 306 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 325 307 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); … … 329 311 } 330 312 331 Expression * Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {313 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 332 314 offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) ); 333 315 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) ); … … 336 318 } 337 319 338 Expression * Mutator::mutate( AttrExpr *attrExpr ) {320 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 339 321 attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) ); 340 322 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) ); … … 347 329 } 348 330 349 Expression * Mutator::mutate( LogicalExpr *logicalExpr ) {331 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) { 350 332 logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) ); 351 333 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) ); … … 355 337 } 356 338 357 Expression * Mutator::mutate( ConditionalExpr *conditionalExpr ) {339 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) { 358 340 conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) ); 359 341 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) ); … … 364 346 } 365 347 366 Expression * Mutator::mutate( CommaExpr *commaExpr ) {348 Expression *Mutator::mutate( CommaExpr *commaExpr ) { 367 349 commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) ); 368 350 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) ); … … 372 354 } 373 355 374 Expression * Mutator::mutate( TypeExpr *typeExpr ) {356 Expression *Mutator::mutate( TypeExpr *typeExpr ) { 375 357 typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) ); 376 358 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) ); … … 379 361 } 380 362 381 Expression * Mutator::mutate( AsmExpr *asmExpr ) {363 Expression *Mutator::mutate( AsmExpr *asmExpr ) { 382 364 asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) ); 383 365 asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) ); … … 404 386 } 405 387 406 Expression * Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {388 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 407 389 compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) ); 408 390 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) ); … … 411 393 } 412 394 413 Expression * Mutator::mutate( RangeExpr *rangeExpr ) {395 Expression *Mutator::mutate( RangeExpr *rangeExpr ) { 414 396 rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) ); 415 397 rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) ); … … 418 400 } 419 401 420 Expression * Mutator::mutate( UntypedTupleExpr *tupleExpr ) {402 Expression *Mutator::mutate( UntypedTupleExpr *tupleExpr ) { 421 403 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 422 404 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); … … 425 407 } 426 408 427 Expression * Mutator::mutate( TupleExpr *tupleExpr ) {409 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 428 410 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 429 411 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); … … 432 414 } 433 415 434 Expression * Mutator::mutate( TupleIndexExpr *tupleExpr ) {416 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) { 435 417 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 436 418 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); … … 439 421 } 440 422 441 Expression * Mutator::mutate( TupleAssignExpr *assignExpr ) {423 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 442 424 assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) ); 443 425 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) ); … … 446 428 } 447 429 448 Expression * Mutator::mutate( StmtExpr *stmtExpr ) {430 Expression *Mutator::mutate( StmtExpr *stmtExpr ) { 449 431 stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) ); 450 432 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) ); … … 455 437 } 456 438 457 Expression * Mutator::mutate( UniqueExpr *uniqueExpr ) {439 Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) { 458 440 uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) ); 459 441 uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) ); … … 462 444 } 463 445 464 Expression * Mutator::mutate( UntypedInitExpr * initExpr ) {446 Expression *Mutator::mutate( UntypedInitExpr * initExpr ) { 465 447 initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) ); 466 448 initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) ); … … 470 452 } 471 453 472 Expression * Mutator::mutate( InitExpr * initExpr ) {454 Expression *Mutator::mutate( InitExpr * initExpr ) { 473 455 initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) ); 474 456 initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) ); … … 479 461 480 462 481 Type * Mutator::mutate( VoidType *voidType ) {463 Type *Mutator::mutate( VoidType *voidType ) { 482 464 mutateAll( voidType->get_forall(), *this ); 483 465 return voidType; 484 466 } 485 467 486 Type * Mutator::mutate( BasicType *basicType ) {468 Type *Mutator::mutate( BasicType *basicType ) { 487 469 mutateAll( basicType->get_forall(), *this ); 488 470 return basicType; 489 471 } 490 472 491 Type * Mutator::mutate( PointerType *pointerType ) {473 Type *Mutator::mutate( PointerType *pointerType ) { 492 474 mutateAll( pointerType->get_forall(), *this ); 493 475 pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) ); … … 495 477 } 496 478 497 Type * Mutator::mutate( ArrayType *arrayType ) {479 Type *Mutator::mutate( ArrayType *arrayType ) { 498 480 mutateAll( arrayType->get_forall(), *this ); 499 481 arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) ); … … 502 484 } 503 485 504 Type * Mutator::mutate( ReferenceType *refType ) {486 Type *Mutator::mutate( ReferenceType *refType ) { 505 487 mutateAll( refType->get_forall(), *this ); 506 488 refType->set_base( maybeMutate( refType->get_base(), *this ) ); … … 508 490 } 509 491 510 Type * Mutator::mutate( FunctionType *functionType ) {492 Type *Mutator::mutate( FunctionType *functionType ) { 511 493 mutateAll( functionType->get_forall(), *this ); 512 494 mutateAll( functionType->get_returnVals(), *this ); … … 515 497 } 516 498 517 Type * Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {499 Type *Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) { 518 500 mutateAll( aggregateUseType->get_forall(), *this ); 519 501 mutateAll( aggregateUseType->get_parameters(), *this ); … … 521 503 } 522 504 523 Type * Mutator::mutate( StructInstType *aggregateUseType ) {505 Type *Mutator::mutate( StructInstType *aggregateUseType ) { 524 506 handleReferenceToType( aggregateUseType ); 525 507 return aggregateUseType; 526 508 } 527 509 528 Type * Mutator::mutate( UnionInstType *aggregateUseType ) {510 Type *Mutator::mutate( UnionInstType *aggregateUseType ) { 529 511 handleReferenceToType( aggregateUseType ); 530 512 return aggregateUseType; 531 513 } 532 514 533 Type * Mutator::mutate( EnumInstType *aggregateUseType ) {515 Type *Mutator::mutate( EnumInstType *aggregateUseType ) { 534 516 handleReferenceToType( aggregateUseType ); 535 517 return aggregateUseType; 536 518 } 537 519 538 Type * Mutator::mutate( TraitInstType *aggregateUseType ) {520 Type *Mutator::mutate( TraitInstType *aggregateUseType ) { 539 521 handleReferenceToType( aggregateUseType ); 540 522 mutateAll( aggregateUseType->get_members(), *this ); … … 542 524 } 543 525 544 Type * Mutator::mutate( TypeInstType *aggregateUseType ) {526 Type *Mutator::mutate( TypeInstType *aggregateUseType ) { 545 527 handleReferenceToType( aggregateUseType ); 546 528 return aggregateUseType; 547 529 } 548 530 549 Type * Mutator::mutate( TupleType *tupleType ) {531 Type *Mutator::mutate( TupleType *tupleType ) { 550 532 mutateAll( tupleType->get_forall(), *this ); 551 533 mutateAll( tupleType->get_types(), *this ); … … 554 536 } 555 537 556 Type * Mutator::mutate( TypeofType *typeofType ) {538 Type *Mutator::mutate( TypeofType *typeofType ) { 557 539 assert( typeofType->get_expr() ); 558 540 typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) ); … … 560 542 } 561 543 562 Type * Mutator::mutate( AttrType *attrType ) {544 Type *Mutator::mutate( AttrType *attrType ) { 563 545 if ( attrType->get_isType() ) { 564 546 assert( attrType->get_type() ); … … 571 553 } 572 554 573 Type * Mutator::mutate( VarArgsType *varArgsType ) {555 Type *Mutator::mutate( VarArgsType *varArgsType ) { 574 556 mutateAll( varArgsType->get_forall(), *this ); 575 557 return varArgsType; 576 558 } 577 559 578 Type * Mutator::mutate( ZeroType *zeroType ) {560 Type *Mutator::mutate( ZeroType *zeroType ) { 579 561 mutateAll( zeroType->get_forall(), *this ); 580 562 return zeroType; 581 563 } 582 564 583 Type * Mutator::mutate( OneType *oneType ) {565 Type *Mutator::mutate( OneType *oneType ) { 584 566 mutateAll( oneType->get_forall(), *this ); 585 567 return oneType; … … 587 569 588 570 589 Designation * Mutator::mutate( Designation * designation ) {571 Designation *Mutator::mutate( Designation * designation ) { 590 572 mutateAll( designation->get_designators(), *this ); 591 573 return designation; 592 574 } 593 575 594 Initializer * Mutator::mutate( SingleInit *singleInit ) {576 Initializer *Mutator::mutate( SingleInit *singleInit ) { 595 577 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); 596 578 return singleInit; 597 579 } 598 580 599 Initializer * Mutator::mutate( ListInit *listInit ) {581 Initializer *Mutator::mutate( ListInit *listInit ) { 600 582 mutateAll( listInit->get_designations(), *this ); 601 583 mutateAll( listInit->get_initializers(), *this ); … … 603 585 } 604 586 605 Initializer * Mutator::mutate( ConstructorInit *ctorInit ) {587 Initializer *Mutator::mutate( ConstructorInit *ctorInit ) { 606 588 ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) ); 607 589 ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) ); … … 611 593 612 594 613 Subrange * Mutator::mutate( Subrange *subrange ) {595 Subrange *Mutator::mutate( Subrange *subrange ) { 614 596 return subrange; 615 597 } 616 598 617 599 618 Constant * Mutator::mutate( Constant *constant ) {600 Constant *Mutator::mutate( Constant *constant ) { 619 601 return constant; 620 602 } -
src/SynTree/Mutator.h
r212c421e rf22b7aef 49 49 virtual Statement* mutate( CatchStmt *catchStmt ); 50 50 virtual Statement* mutate( FinallyStmt *catchStmt ); 51 virtual Statement* mutate( WaitForStmt *waitforStmt );52 51 virtual NullStmt* mutate( NullStmt *nullStmt ); 53 52 virtual Statement* mutate( DeclStmt *declStmt ); -
src/SynTree/Statement.cc
r212c421e rf22b7aef 419 419 } 420 420 421 WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels ) {422 timeout.time = nullptr;423 timeout.statement = nullptr;424 timeout.condition = nullptr;425 orelse .statement = nullptr;426 orelse .condition = nullptr;427 }428 429 WaitForStmt::WaitForStmt( const WaitForStmt & other ) : Statement( other ) {430 clauses.reserve( other.clauses.size() );431 for( auto & ocl : other.clauses ) {432 clauses.emplace_back();433 clauses.back().target.function = ocl.target.function->clone();434 cloneAll( ocl.target.arguments, clauses.back().target.arguments );435 clauses.back().statement = ocl.statement->clone();436 clauses.back().condition = ocl.condition->clone();437 }438 439 timeout.time = other.timeout.time ->clone();440 timeout.statement = other.timeout.statement->clone();441 timeout.condition = other.timeout.condition->clone();442 orelse .statement = other.orelse .statement->clone();443 orelse .condition = other.orelse .condition->clone();444 }445 446 WaitForStmt::~WaitForStmt() {447 for( auto & clause : clauses ) {448 delete clause.target.function;449 deleteAll( clause.target.arguments );450 delete clause.statement;451 delete clause.condition;452 }453 454 delete timeout.time;455 delete timeout.statement;456 delete timeout.condition;457 458 delete orelse.statement;459 delete orelse.condition;460 }461 462 void WaitForStmt::print( std::ostream &os, int indent ) const {463 os << "Waitfor Statement" << endl;464 os << string( indent + 2, ' ' ) << "with block:" << endl;465 os << string( indent + 4, ' ' );466 // block->print( os, indent + 4 );467 }468 469 421 NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {} 470 422 NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {} -
src/SynTree/Statement.h
r212c421e rf22b7aef 19 19 #include <list> // for list 20 20 #include <memory> // for allocator 21 #include <vector> // for vector22 21 23 22 #include "BaseSyntaxNode.h" // for BaseSyntaxNode … … 393 392 }; 394 393 395 class WaitForStmt : public Statement {396 public:397 398 struct Target {399 Expression * function;400 std::list<Expression * > arguments;401 };402 403 struct Clause {404 Target target;405 Statement * statement;406 Expression * condition;407 };408 409 WaitForStmt( std::list<Label> labels = noLabels );410 WaitForStmt( const WaitForStmt & );411 virtual ~WaitForStmt();412 413 std::vector<Clause> clauses;414 415 struct {416 Expression * time;417 Statement * statement;418 Expression * condition;419 } timeout;420 421 struct {422 Statement * statement;423 Expression * condition;424 } orelse;425 426 virtual WaitForStmt *clone() const { return new WaitForStmt( *this ); }427 virtual void accept( Visitor &v ) { v.visit( this ); }428 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }429 virtual void print( std::ostream &os, int indent = 0 ) const;430 431 };432 433 394 434 395 // represents a declaration that occurs as part of a compound statement -
src/SynTree/SynTree.h
r212c421e rf22b7aef 54 54 class CatchStmt; 55 55 class FinallyStmt; 56 class WaitForStmt;57 56 class NullStmt; 58 57 class DeclStmt; -
src/SynTree/Visitor.cc
r212c421e rf22b7aef 155 155 } 156 156 157 void Visitor::visit( WaitForStmt *waitforStmt ) {158 for( auto & clause : waitforStmt->clauses ) {159 maybeAccept( clause.target.function, *this );160 acceptAll( clause.target.arguments, *this );161 162 maybeAccept( clause.statement, *this );163 maybeAccept( clause.condition, *this );164 }165 166 maybeAccept( waitforStmt->timeout.time, *this );167 maybeAccept( waitforStmt->timeout.statement, *this );168 maybeAccept( waitforStmt->timeout.condition, *this );169 maybeAccept( waitforStmt->orelse.statement, *this );170 maybeAccept( waitforStmt->orelse.condition, *this );171 }172 173 157 void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) { 174 158 } -
src/SynTree/Visitor.h
r212c421e rf22b7aef 51 51 virtual void visit( CatchStmt *catchStmt ); 52 52 virtual void visit( FinallyStmt *finallyStmt ); 53 virtual void visit( WaitForStmt *waitforStmt );54 53 virtual void visit( NullStmt *nullStmt ); 55 54 virtual void visit( DeclStmt *declStmt ); -
src/libcfa/concurrency/invoke.h
r212c421e rf22b7aef 28 28 #define thread_local _Thread_local 29 29 30 typedef void (*fptr_t)();31 32 30 struct spinlock { 33 31 volatile int lock; … … 52 50 void append( struct __thread_queue_t *, struct thread_desc * ); 53 51 struct thread_desc * pop_head( struct __thread_queue_t * ); 54 struct thread_desc * remove( struct __thread_queue_t *, struct thread_desc ** );55 52 56 53 void ?{}( struct __condition_stack_t & ); … … 90 87 struct __condition_stack_t signal_stack; // stack of conditions to run next once we exit the monitor 91 88 unsigned int recursion; // monitor routines can be called recursively, we need to keep track of that 92 93 struct __acceptable_t * acceptables; // list of acceptable functions, null if any 94 unsigned short acceptable_count; // number of acceptable functions 95 short accepted_index; // the index of the accepted function, -1 if none 96 }; 89 }; 97 90 98 91 struct thread_desc { 99 // Core threading fields100 92 struct coroutine_desc cor; // coroutine body used to store context 101 93 struct monitor_desc mon; // monitor body used for mutual exclusion 102 103 // Link lists fields104 94 struct thread_desc * next; // instrusive link field for threads 105 106 // Current status related to monitors107 95 struct monitor_desc ** current_monitors; // currently held monitors 108 96 unsigned short current_monitor_count; // number of currently held monitors 109 fptr_t current_monitor_func; // last function that acquired monitors 110 }; 97 }; 111 98 112 99 #endif //_INVOKE_H_ -
src/libcfa/concurrency/kernel.c
r212c421e rf22b7aef 322 322 void ScheduleThread( thread_desc * thrd ) { 323 323 // if( !thrd ) return; 324 verify( thrd );325 verify( thrd->cor.state != Halted );324 assert( thrd ); 325 assert( thrd->cor.state != Halted ); 326 326 327 327 verify( disable_preempt_count > 0 ); … … 366 366 367 367 void BlockInternal( thread_desc * thrd ) { 368 assert(thrd);369 368 disable_interrupts(); 370 369 assert( thrd->cor.state != Halted ); … … 380 379 381 380 void BlockInternal( spinlock * lock, thread_desc * thrd ) { 382 assert(thrd);383 381 disable_interrupts(); 384 382 this_processor->finish.action_code = Release_Schedule; … … 668 666 } 669 667 670 thread_desc * remove( __thread_queue_t * this, thread_desc ** it ) {671 thread_desc * thrd = *it;672 verify( thrd );673 674 (*it) = thrd->next;675 676 if( this->tail == &thrd->next ) {677 this->tail = it;678 }679 680 thrd->next = NULL;681 682 verify( (this->head == NULL) == (&this->head == this->tail) );683 verify( *this->tail == NULL );684 return thrd;685 }686 687 668 void ?{}( __condition_stack_t & this ) { 688 669 this.top = NULL; -
src/libcfa/concurrency/monitor
r212c421e rf22b7aef 23 23 24 24 static inline void ?{}(monitor_desc & this) { 25 (this.lock){};26 25 this.owner = NULL; 27 (this.entry_queue){};28 (this.signal_stack){};29 26 this.recursion = 0; 30 this.acceptables = NULL;31 this.acceptable_count = 0;32 this.accepted_index = -1;33 27 } 34 28 … … 38 32 monitor_desc ** prev_mntrs; 39 33 unsigned short prev_count; 40 fptr_t prev_func;41 34 }; 42 35 … … 45 38 } 46 39 47 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count , void (*func)());40 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count ); 48 41 void ^?{}( monitor_guard_t & this ); 49 42 … … 96 89 uintptr_t front( condition * this ); 97 90 98 //-----------------------------------------------------------------------------99 // External scheduling100 101 91 struct __acceptable_t { 102 fptr_t func;92 void (*func)(void); 103 93 unsigned short count; 104 monitor_desc * * monitors;94 monitor_desc * monitors[1]; 105 95 }; 106 96 107 int __accept_internal( unsigned short count, __acceptable_t * acceptables);97 void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) ); 108 98 109 99 // Local Variables: // -
src/libcfa/concurrency/monitor.c
r212c421e rf22b7aef 25 25 static inline void set_owner( monitor_desc * this, thread_desc * owner ); 26 26 static inline thread_desc * next_thread( monitor_desc * this ); 27 static inline int is_accepted( thread_desc * owner, monitor_desc * this, monitor_desc ** group, int group_cnt, void (*func)() );28 27 29 28 static inline void lock_all( spinlock ** locks, unsigned short count ); … … 35 34 static inline void restore_recursion( monitor_desc ** ctx, unsigned int * /*in */ recursions, unsigned short count ); 36 35 37 static inline void init ( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria );38 static inline void init_push( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria );39 40 36 static inline thread_desc * check_condition( __condition_criterion_t * ); 41 37 static inline void brand_condition( condition * ); 42 38 static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val ); 43 39 44 static inline thread_desc * search_entry_queue( __acceptable_t * acceptables, int acc_count, monitor_desc ** monitors, int count );45 46 //-----------------------------------------------------------------------------47 // Useful defines48 #define wait_ctx(thrd, user_info) /* Create the necessary information to use the signaller stack */ \49 __condition_node_t waiter = { thrd, count, user_info }; /* Create the node specific to this wait operation */ \50 __condition_criterion_t criteria[count]; /* Create the creteria this wait operation needs to wake up */ \51 init( count, monitors, &waiter, criteria ); /* Link everything together */ \52 53 #define wait_ctx_primed(thrd, user_info) /* Create the necessary information to use the signaller stack */ \54 __condition_node_t waiter = { thrd, count, user_info }; /* Create the node specific to this wait operation */ \55 __condition_criterion_t criteria[count]; /* Create the creteria this wait operation needs to wake up */ \56 init_push( count, monitors, &waiter, criteria ); /* Link everything together and push it to the AS-Stack */ \57 58 #define monitor_ctx( mons, cnt ) /* Define that create the necessary struct for internal/external scheduling operations */ \59 monitor_desc ** monitors = mons; /* Save the targeted monitors */ \60 unsigned short count = cnt; /* Save the count to a local variable */ \61 unsigned int recursions[ count ]; /* Save the current recursion levels to restore them later */ \62 spinlock * locks [ count ]; /* We need to pass-in an array of locks to BlockInternal */ \63 64 40 //----------------------------------------------------------------------------- 65 41 // Enter/Leave routines … … 67 43 68 44 extern "C" { 69 // Enter single monitor 70 static void __enter_monitor_desc( monitor_desc * this, monitor_desc ** group, int group_cnt, void (*func)() ) { 71 // Lock the monitor spinlock, lock_yield to reduce contention 45 void __enter_monitor_desc( monitor_desc * this ) { 72 46 lock_yield( &this->lock DEBUG_CTX2 ); 73 47 thread_desc * thrd = this_thread; 74 48 75 LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner); 76 77 this->accepted_index = -1; 49 // LIB_DEBUG_PRINT_SAFE("%p Entering %p (o: %p, r: %i)\n", thrd, this, this->owner, this->recursion); 50 78 51 if( !this->owner ) { 79 // No one has the monitor, just take it52 //No one has the monitor, just take it 80 53 set_owner( this, thrd ); 81 82 LIB_DEBUG_PRINT_SAFE("Kernel : mon is free \n");83 54 } 84 55 else if( this->owner == thrd) { 85 // We already have the monitor, just not how many times we took it56 //We already have the monitor, just not how many times we took it 86 57 verify( this->recursion > 0 ); 87 58 this->recursion += 1; 88 89 LIB_DEBUG_PRINT_SAFE("Kernel : mon already owned \n");90 }91 else if( (this->accepted_index = is_accepted( thrd, this, group, group_cnt, func)) >= 0 ) {92 // Some one was waiting for us, enter93 set_owner( this, thrd );94 95 LIB_DEBUG_PRINT_SAFE("Kernel : mon accepts \n");96 59 } 97 60 else { 98 LIB_DEBUG_PRINT_SAFE("Kernel : blocking \n"); 99 100 // Some one else has the monitor, wait in line for it 61 //Some one else has the monitor, wait in line for it 101 62 append( &this->entry_queue, thrd ); 63 // LIB_DEBUG_PRINT_SAFE("%p Blocking on entry\n", thrd); 102 64 BlockInternal( &this->lock ); 103 65 104 LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entered mon %p\n", thrd, this); 105 106 // BlockInternal will unlock spinlock, no need to unlock ourselves 66 //BlockInternal will unlock spinlock, no need to unlock ourselves 107 67 return; 108 68 } 109 69 110 LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entered mon %p\n", thrd, this);111 112 // Release the lock and leave113 70 unlock( &this->lock ); 114 71 return; 115 72 } 116 73 117 // Leave single monitor 74 // leave pseudo code : 75 // TODO 118 76 void __leave_monitor_desc( monitor_desc * this ) { 119 // Lock the monitor spinlock, lock_yield to reduce contention120 77 lock_yield( &this->lock DEBUG_CTX2 ); 121 78 79 // LIB_DEBUG_PRINT_SAFE("%p Leaving %p (o: %p, r: %i). ", this_thread, this, this->owner, this->recursion); 122 80 verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread, this->owner, this->recursion ); 123 81 124 // Leaving a recursion level, decrement the counter82 //Leaving a recursion level, decrement the counter 125 83 this->recursion -= 1; 126 84 127 // If we haven't left the last level of recursion128 // it means we don't need to do anything85 //If we haven't left the last level of recursion 86 //it means we don't need to do anything 129 87 if( this->recursion != 0) { 130 88 unlock( &this->lock ); … … 132 90 } 133 91 134 // Get the next thread, will be null on low contention monitor135 92 thread_desc * new_owner = next_thread( this ); 136 93 137 // We can now let other threads in safely94 //We can now let other threads in safely 138 95 unlock( &this->lock ); 96 97 // LIB_DEBUG_PRINT_SAFE("Next owner is %p\n", new_owner); 139 98 140 99 //We need to wake-up the thread … … 142 101 } 143 102 144 // Leave the thread monitor145 // last routine called by a thread.146 // Should never return147 103 void __leave_thread_monitor( thread_desc * thrd ) { 148 104 monitor_desc * this = &thrd->mon; 149 150 // Lock the monitor now151 105 lock_yield( &this->lock DEBUG_CTX2 ); 152 106 … … 157 111 verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion ); 158 112 159 // Leaving a recursion level, decrement the counter113 //Leaving a recursion level, decrement the counter 160 114 this->recursion -= 1; 161 115 162 // If we haven't left the last level of recursion 163 // it must mean there is an error 164 if( this->recursion != 0) { abortf("Thread internal monitor has unbalanced recursion"); } 165 166 // Fetch the next thread, can be null 116 //If we haven't left the last level of recursion 117 //it means we don't need to do anything 118 if( this->recursion != 0) { 119 unlock( &this->lock ); 120 return; 121 } 122 167 123 thread_desc * new_owner = next_thread( this ); 168 124 169 // Leave the thread, this will unlock the spinlock170 // Use leave thread instead of BlockInternal which is171 // specialized for this case and supports null new_owner172 125 LeaveThread( &this->lock, new_owner ); 173 174 // Control flow should never reach here! 175 } 176 } 177 178 // Enter multiple monitor 179 // relies on the monitor array being sorted 180 static inline void enter(monitor_desc ** monitors, int count, void (*func)() ) { 126 } 127 } 128 129 static inline void enter(monitor_desc ** monitors, int count) { 181 130 for(int i = 0; i < count; i++) { 182 __enter_monitor_desc( monitors[i], monitors, count, func ); 183 } 184 } 185 186 // Leave multiple monitor 187 // relies on the monitor array being sorted 131 __enter_monitor_desc( monitors[i] ); 132 } 133 } 134 188 135 static inline void leave(monitor_desc ** monitors, int count) { 189 136 for(int i = count - 1; i >= 0; i--) { … … 192 139 } 193 140 194 // Ctor for monitor guard 195 // Sorts monitors before entering 196 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count, void (*func)() ) { 197 // Store current array 141 void ?{}( monitor_guard_t & this, monitor_desc ** m, int count ) { 198 142 this.m = m; 199 143 this.count = count; 200 201 // Sort monitors based on address -> TODO use a sort specialized for small numbers202 144 qsort(this.m, count); 203 204 // Save previous thread context 145 enter( this.m, this.count ); 146 205 147 this.prev_mntrs = this_thread->current_monitors; 206 148 this.prev_count = this_thread->current_monitor_count; 207 this.prev_func = this_thread->current_monitor_func; 208 209 // Update thread context (needed for conditions) 149 210 150 this_thread->current_monitors = m; 211 151 this_thread->current_monitor_count = count; 212 this_thread->current_monitor_func = func; 213 214 // Enter the monitors in order 215 enter( this.m, this.count, func ); 216 } 217 218 219 // Dtor for monitor guard 152 } 153 220 154 void ^?{}( monitor_guard_t & this ) { 221 // Leave the monitors in order222 155 leave( this.m, this.count ); 223 156 224 // Restore thread context225 157 this_thread->current_monitors = this.prev_mntrs; 226 158 this_thread->current_monitor_count = this.prev_count; 227 this_thread->current_monitor_func = this.prev_func; 228 } 229 230 //----------------------------------------------------------------------------- 231 // Internal scheduling types 159 } 160 232 161 void ?{}(__condition_node_t & this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) { 233 162 this.waiting_thread = waiting_thread; … … 254 183 // Internal scheduling 255 184 void wait( condition * this, uintptr_t user_info = 0 ) { 185 // LIB_DEBUG_PRINT_SAFE("Waiting\n"); 186 256 187 brand_condition( this ); 257 188 258 // Check that everything is as expected189 //Check that everything is as expected 259 190 assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors ); 260 191 verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count ); 261 192 verifyf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count ); 262 193 263 // Create storage for monitor context 264 monitor_ctx( this->monitors, this->monitor_count ); 265 266 // Create the node specific to this wait operation 267 wait_ctx( this_thread, user_info ); 268 269 // Append the current wait operation to the ones already queued on the condition 270 // We don't need locks for that since conditions must always be waited on inside monitor mutual exclusion 194 unsigned short count = this->monitor_count; 195 unsigned int recursions[ count ]; //Save the current recursion levels to restore them later 196 spinlock * locks [ count ]; //We need to pass-in an array of locks to BlockInternal 197 198 // LIB_DEBUG_PRINT_SAFE("count %i\n", count); 199 200 __condition_node_t waiter = { (thread_desc*)this_thread, count, user_info }; 201 202 __condition_criterion_t criteria[count]; 203 for(int i = 0; i < count; i++) { 204 (criteria[i]){ this->monitors[i], &waiter }; 205 // LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] ); 206 } 207 208 waiter.criteria = criteria; 271 209 append( &this->blocked, &waiter ); 272 210 273 // Lock all monitors (aggregates the lock them as well) 274 lock_all( monitors, locks, count ); 275 276 // DON'T unlock, ask the kernel to do it 277 278 // Save monitor state 279 save_recursion( monitors, recursions, count ); 280 281 // Find the next thread(s) to run 211 lock_all( this->monitors, locks, count ); 212 save_recursion( this->monitors, recursions, count ); 213 //DON'T unlock, ask the kernel to do it 214 215 //Find the next thread(s) to run 282 216 unsigned short thread_count = 0; 283 217 thread_desc * threads[ count ]; … … 286 220 } 287 221 288 // Remove any duplicate threads289 222 for( int i = 0; i < count; i++) { 290 thread_desc * new_owner = next_thread( monitors[i] );223 thread_desc * new_owner = next_thread( this->monitors[i] ); 291 224 thread_count = insert_unique( threads, thread_count, new_owner ); 292 225 } 226 227 // LIB_DEBUG_PRINT_SAFE("Will unblock: "); 228 for(int i = 0; i < thread_count; i++) { 229 // LIB_DEBUG_PRINT_SAFE("%p ", threads[i]); 230 } 231 // LIB_DEBUG_PRINT_SAFE("\n"); 293 232 294 233 // Everything is ready to go to sleep … … 296 235 297 236 298 // WE WOKE UP299 300 301 // We are back, restore the owners and recursions237 //WE WOKE UP 238 239 240 //We are back, restore the owners and recursions 302 241 lock_all( locks, count ); 303 restore_recursion( monitors, recursions, count );242 restore_recursion( this->monitors, recursions, count ); 304 243 unlock_all( locks, count ); 305 244 } 306 245 307 246 bool signal( condition * this ) { 308 if( is_empty( this ) ) { return false; } 247 if( is_empty( this ) ) { 248 // LIB_DEBUG_PRINT_SAFE("Nothing to signal\n"); 249 return false; 250 } 309 251 310 252 //Check that everything is as expected 311 253 verify( this->monitors ); 312 254 verify( this->monitor_count != 0 ); 255 256 unsigned short count = this->monitor_count; 313 257 314 258 //Some more checking in debug … … 317 261 if ( this->monitor_count != this_thrd->current_monitor_count ) { 318 262 abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", this, this->monitor_count, this_thrd->current_monitor_count ); 319 } 263 } // if 320 264 321 265 for(int i = 0; i < this->monitor_count; i++) { 322 266 if ( this->monitors[i] != this_thrd->current_monitors[i] ) { 323 267 abortf( "Signal on condition %p made with different monitor, expected %p got %i", this, this->monitors[i], this_thrd->current_monitors[i] ); 324 } 268 } // if 325 269 } 326 270 ); 327 271 328 unsigned short count = this->monitor_count; 329 330 // Lock all monitors 272 //Lock all the monitors 331 273 lock_all( this->monitors, NULL, count ); 274 // LIB_DEBUG_PRINT_SAFE("Signalling"); 332 275 333 276 //Pop the head of the waiting queue … … 337 280 for(int i = 0; i < count; i++) { 338 281 __condition_criterion_t * crit = &node->criteria[i]; 282 // LIB_DEBUG_PRINT_SAFE(" %p", crit->target); 339 283 assert( !crit->ready ); 340 284 push( &crit->target->signal_stack, crit ); 341 285 } 342 286 287 // LIB_DEBUG_PRINT_SAFE("\n"); 288 343 289 //Release 344 290 unlock_all( this->monitors, count ); … … 348 294 349 295 bool signal_block( condition * this ) { 350 if( !this->blocked.head ) { return false; } 296 if( !this->blocked.head ) { 297 LIB_DEBUG_PRINT_SAFE("Nothing to signal\n"); 298 return false; 299 } 351 300 352 301 //Check that everything is as expected … … 354 303 verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count ); 355 304 356 // Create storage for monitor context 357 monitor_ctx( this->monitors, this->monitor_count ); 358 359 // Lock all monitors (aggregates the locks them as well) 360 lock_all( monitors, locks, count ); 361 362 // Create the node specific to this wait operation 363 wait_ctx_primed( this_thread, 0 ) 305 unsigned short count = this->monitor_count; 306 unsigned int recursions[ count ]; //Save the current recursion levels to restore them later 307 spinlock * locks [ count ]; //We need to pass-in an array of locks to BlockInternal 308 309 lock_all( this->monitors, locks, count ); 310 311 //create creteria 312 __condition_node_t waiter = { (thread_desc*)this_thread, count, 0 }; 313 314 __condition_criterion_t criteria[count]; 315 for(int i = 0; i < count; i++) { 316 (criteria[i]){ this->monitors[i], &waiter }; 317 // LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] ); 318 push( &criteria[i].target->signal_stack, &criteria[i] ); 319 } 320 321 waiter.criteria = criteria; 364 322 365 323 //save contexts 366 save_recursion( monitors, recursions, count );324 save_recursion( this->monitors, recursions, count ); 367 325 368 326 //Find the thread to run 369 327 thread_desc * signallee = pop_head( &this->blocked )->waiting_thread; 370 328 for(int i = 0; i < count; i++) { 371 set_owner( monitors[i], signallee ); 372 } 329 set_owner( this->monitors[i], signallee ); 330 } 331 332 LIB_DEBUG_PRINT_SAFE( "Waiting on signal block\n" ); 373 333 374 334 //Everything is ready to go to sleep … … 376 336 377 337 378 // WE WOKE UP 379 338 339 340 LIB_DEBUG_PRINT_SAFE( "Back from signal block\n" ); 380 341 381 342 //We are back, restore the owners and recursions 382 343 lock_all( locks, count ); 383 restore_recursion( monitors, recursions, count );344 restore_recursion( this->monitors, recursions, count ); 384 345 unlock_all( locks, count ); 385 346 … … 387 348 } 388 349 389 // Access the user_info of the thread waiting at the front of the queue390 350 uintptr_t front( condition * this ) { 391 351 verifyf( !is_empty(this), … … 398 358 //----------------------------------------------------------------------------- 399 359 // Internal scheduling 400 int __accept_internal( unsigned short acc_count, __acceptable_t * acceptables ) { 401 thread_desc * thrd = this_thread; 402 403 // Create storage for monitor context 404 monitor_ctx( acceptables->monitors, acceptables->count ); 405 406 // Lock all monitors (aggregates the lock them as well) 407 lock_all( monitors, locks, count ); 408 409 // Create the node specific to this wait operation 410 wait_ctx_primed( thrd, 0 ); 411 412 // Check if the entry queue 413 thread_desc * next = search_entry_queue( acceptables, acc_count, monitors, count ); 414 415 LIB_DEBUG_PRINT_SAFE("Owner(s) :"); 416 for(int i = 0; i < count; i++) { 417 LIB_DEBUG_PRINT_SAFE(" %p", monitors[i]->owner ); 418 } 419 LIB_DEBUG_PRINT_SAFE("\n"); 420 421 LIB_DEBUG_PRINT_SAFE("Passing mon to %p\n", next); 422 423 if( !next ) { 424 // Update acceptables on the current monitors 425 for(int i = 0; i < count; i++) { 426 monitors[i]->acceptables = acceptables; 427 monitors[i]->acceptable_count = acc_count; 428 } 429 } 430 else { 431 for(int i = 0; i < count; i++) { 432 set_owner( monitors[i], next ); 433 } 434 } 435 436 437 save_recursion( monitors, recursions, count ); 438 439 440 // Everything is ready to go to sleep 441 BlockInternal( locks, count, &next, next ? 1 : 0 ); 442 443 444 //WE WOKE UP 445 446 447 //We are back, restore the owners and recursions 448 lock_all( locks, count ); 449 restore_recursion( monitors, recursions, count ); 450 int acc_idx = monitors[0]->accepted_index; 451 unlock_all( locks, count ); 452 453 return acc_idx; 360 void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) ) { 361 // thread_desc * this = this_thread; 362 363 // unsigned short count = this->current_monitor_count; 364 // unsigned int recursions[ count ]; //Save the current recursion levels to restore them later 365 // spinlock * locks [ count ]; //We need to pass-in an array of locks to BlockInternal 366 367 // lock_all( this->current_monitors, locks, count ); 368 369 370 371 372 373 // // // Everything is ready to go to sleep 374 // // BlockInternal( locks, count, threads, thread_count ); 375 376 377 // //WE WOKE UP 378 379 380 // //We are back, restore the owners and recursions 381 // lock_all( locks, count ); 382 // restore_recursion( this->monitors, recursions, count ); 383 // unlock_all( locks, count ); 454 384 } 455 385 … … 485 415 } 486 416 487 static inline int is_accepted( thread_desc * owner, monitor_desc * this, monitor_desc ** group, int group_cnt, void (*func)() ) {488 __acceptable_t* accs = this->acceptables; // Optim489 int acc_cnt = this->acceptable_count;490 491 // Check if there are any acceptable functions492 if( !accs ) return -1;493 494 // If this isn't the first monitor to test this, there is no reason to repeat the test.495 if( this != group[0] ) return group[0]->accepted_index;496 497 // For all acceptable functions check if this is the current function.498 OUT_LOOP:499 for( int i = 0; i < acc_cnt; i++ ) {500 __acceptable_t * acc = &accs[i];501 502 // if function matches, check the monitors503 if( acc->func == func ) {504 505 // If the group count is different then it can't be a match506 if( acc->count != group_cnt ) return -1;507 508 // Check that all the monitors match509 for( int j = 0; j < group_cnt; j++ ) {510 // If not a match, check next function511 if( acc->monitors[j] != group[j] ) continue OUT_LOOP;512 }513 514 // It's a complete match, accept the call515 return i;516 }517 }518 519 // No function matched520 return -1;521 }522 523 static inline void init( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria ) {524 for(int i = 0; i < count; i++) {525 (criteria[i]){ monitors[i], waiter };526 }527 528 waiter->criteria = criteria;529 }530 531 static inline void init_push( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria ) {532 for(int i = 0; i < count; i++) {533 (criteria[i]){ monitors[i], waiter };534 push( &criteria[i].target->signal_stack, &criteria[i] );535 }536 537 waiter->criteria = criteria;538 }539 540 417 static inline void lock_all( spinlock ** locks, unsigned short count ) { 541 418 for( int i = 0; i < count; i++ ) { … … 628 505 } 629 506 630 631 static inline bool match( __acceptable_t * acc, thread_desc * thrd ) {632 verify( thrd );633 verify( acc );634 if( acc->func != thrd->current_monitor_func ) return false;635 636 return true;637 }638 639 static inline thread_desc * search_entry_queue( __acceptable_t * acceptables, int acc_count, monitor_desc ** monitors, int count ) {640 641 __thread_queue_t * entry_queue = &monitors[0]->entry_queue;642 643 // For each thread in the entry-queue644 for( thread_desc ** thrd_it = &entry_queue->head;645 *thrd_it;646 thrd_it = &(*thrd_it)->next)647 {648 // For each acceptable check if it matches649 __acceptable_t * acc_end = acceptables + acc_count;650 for( __acceptable_t * acc_it = acceptables; acc_it != acc_end; acc_it++ ) {651 // Check if we have a match652 if( match( acc_it, *thrd_it ) ) {653 654 // If we have a match return it655 // after removeing it from the entry queue656 return remove( entry_queue, thrd_it );657 }658 }659 }660 661 return NULL;662 }663 507 void ?{}( __condition_blocked_queue_t & this ) { 664 508 this.head = NULL; -
src/libcfa/concurrency/preemption.c
r212c421e rf22b7aef 332 332 assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int); 333 333 334 //LIB_DEBUG_PRINT_SAFE("Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );334 LIB_DEBUG_PRINT_SAFE("Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int ); 335 335 // Switch on the code (a.k.a. the sender) to 336 336 switch( info.si_code ) … … 340 340 case SI_TIMER: 341 341 case SI_KERNEL: 342 //LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");342 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n"); 343 343 lock( &event_kernel->lock DEBUG_CTX2 ); 344 344 tick_preemption(); -
src/tests/preempt_longrun/stack.c
r212c421e rf22b7aef 15 15 16 16 void main(worker_t * this) { 17 volatile long longp = 5_021_609ul;18 volatile long longa = 326_417ul;19 volatile long longn = 1l;20 for (volatile long longi = 0; i < p; i++) {17 volatile long p = 5_021_609ul; 18 volatile long a = 326_417ul; 19 volatile long n = 1l; 20 for (volatile long i = 0; i < p; i++) { 21 21 n *= a; 22 22 n %= p; -
src/tests/sched-int-disjoint.c
r212c421e rf22b7aef 3 3 #include <monitor> 4 4 #include <thread> 5 6 #include <time.h>7 5 8 6 static const unsigned long N = 10_000ul; … … 109 107 // Main loop 110 108 int main(int argc, char* argv[]) { 111 rand48seed( time( NULL ) );112 109 all_done = false; 113 110 processor p; -
src/tests/sched-int-wait.c
r212c421e rf22b7aef 5 5 #include <thread> 6 6 7 #include <time.h> 8 9 static const unsigned long N = 2_500ul; 7 static const unsigned long N = 10_000ul; 10 8 11 9 #ifndef PREEMPTION_RATE … … 121 119 // Main 122 120 int main(int argc, char* argv[]) { 123 rand48seed( time( NULL ) );124 121 waiter_left = 4; 125 122 processor p[2];
Note:
See TracChangeset
for help on using the changeset viewer.