- File:
-
- 1 edited
-
libcfa/src/concurrency/preemption.cfa (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/preemption.cfa
r250583e re84ab3d 251 251 bool enabled = __cfaabi_tls.preemption_state.enabled; 252 252 253 // Check if there is a pending preemption254 processor * proc = __cfaabi_tls.this_processor;255 bool pending = proc ? proc->pending_preemption : false;256 if( enabled && pending ) proc->pending_preemption = false;257 258 253 // create a assembler label after 259 254 // marked as clobber all to avoid movement 260 255 __cfaasm_label(check, after); 261 262 // If we can preempt and there is a pending one263 // this is a good time to yield264 if( enabled && pending ) {265 force_yield( __POLL_PREEMPTION );266 }267 256 return enabled; 268 257 } … … 293 282 // marked as clobber all to avoid movement 294 283 __cfaasm_label(get, after); 295 296 // This is used everywhere, to avoid cost, we DO NOT poll pending preemption297 284 return val; 298 285 } … … 371 358 if(!ready) { abort("Preemption should be ready"); } 372 359 373 sigset_t oldset; 374 int ret; 375 ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset); // workaround trac#208: cast should be unnecessary 376 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); } 377 378 ret = sigismember(&oldset, SIGUSR1); 379 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 380 if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); } 381 382 ret = sigismember(&oldset, SIGALRM); 383 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 384 if(ret == 0) { abort("ERROR SIGALRM is enabled"); } 385 386 ret = sigismember(&oldset, SIGTERM); 387 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 388 if(ret == 1) { abort("ERROR SIGTERM is disabled"); } 360 __cfaasm_label(debug, before); 361 362 sigset_t oldset; 363 int ret; 364 ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset); // workaround trac#208: cast should be unnecessary 365 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); } 366 367 ret = sigismember(&oldset, SIGUSR1); 368 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 369 if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); } 370 371 ret = sigismember(&oldset, SIGALRM); 372 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 373 if(ret == 0) { abort("ERROR SIGALRM is enabled"); } 374 375 ret = sigismember(&oldset, SIGTERM); 376 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 377 if(ret == 1) { abort("ERROR SIGTERM is disabled"); } 378 379 __cfaasm_label(debug, after); 389 380 } 390 381 … … 557 548 __cfaasm_label( check ); 558 549 __cfaasm_label( dsable ); 559 //__cfaasm_label( debug );550 __cfaasm_label( debug ); 560 551 561 552 // Check if preemption is safe … … 564 555 if( __cfaasm_in( ip, check ) ) { ready = false; goto EXIT; }; 565 556 if( __cfaasm_in( ip, dsable ) ) { ready = false; goto EXIT; }; 566 //if( __cfaasm_in( ip, debug ) ) { ready = false; goto EXIT; };557 if( __cfaasm_in( ip, debug ) ) { ready = false; goto EXIT; }; 567 558 if( !__cfaabi_tls.preemption_state.enabled) { ready = false; goto EXIT; }; 568 559 if( __cfaabi_tls.preemption_state.in_progress ) { ready = false; goto EXIT; }; … … 670 661 671 662 // Check if it is safe to preempt here 672 if( !preemption_ready( ip ) ) { 673 #if !defined(__CFA_NO_STATISTICS__) 674 __cfaabi_tls.this_stats->ready.threads.preempt.rllfwd++; 675 #endif 676 return; 677 } 663 if( !preemption_ready( ip ) ) { return; } 678 664 679 665 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", __cfaabi_tls.this_processor, __cfaabi_tls.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) ); … … 694 680 695 681 // Preemption can occur here 696 697 #if !defined(__CFA_NO_STATISTICS__)698 __cfaabi_tls.this_stats->ready.threads.preempt.yield++;699 #endif700 682 701 683 force_yield( __ALARM_PREEMPTION ); // Do the actual __cfactx_switch
Note:
See TracChangeset
for help on using the changeset viewer.