Changeset 3e3f236 for libcfa/src/concurrency/preemption.cfa
- Timestamp:
- Dec 10, 2020, 4:00:29 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 97aca3d, b3a0df6
- Parents:
- 6a45bd78 (diff), 297cf18 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/preemption.cfa
r6a45bd78 r3e3f236 354 354 } 355 355 356 //----------------------------------------------------------------------------- 357 // Kernel Signal Debug 358 void __cfaabi_check_preemption() { 359 bool ready = __preemption_enabled(); 360 if(!ready) { abort("Preemption should be ready"); } 361 362 __cfaasm_label(debug, before); 363 364 sigset_t oldset; 365 int ret; 366 ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset); // workaround trac#208: cast should be unnecessary 367 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); } 368 369 ret = sigismember(&oldset, SIGUSR1); 370 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 371 if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); } 372 373 ret = sigismember(&oldset, SIGALRM); 374 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 375 if(ret == 0) { abort("ERROR SIGALRM is enabled"); } 376 377 ret = sigismember(&oldset, SIGTERM); 378 if(ret < 0) { abort("ERROR sigismember returned %d", ret); } 379 if(ret == 1) { abort("ERROR SIGTERM is disabled"); } 380 381 __cfaasm_label(debug, after); 382 } 383 384 #ifdef __CFA_WITH_VERIFY__ 385 bool __cfaabi_dbg_in_kernel() { 386 return !__preemption_enabled(); 387 } 388 #endif 389 356 390 #undef __cfaasm_label 391 392 //----------------------------------------------------------------------------- 393 // Signal handling 357 394 358 395 // sigprocmask wrapper : unblock a single signal … … 405 442 #define RELOC_SUFFIX "" 406 443 #endif 407 #define __cfaasm_label( label ) st atic struct asm_region label = \444 #define __cfaasm_label( label ) struct asm_region label = \ 408 445 ({ \ 409 446 struct asm_region region; \ … … 424 461 #define RELOC_SUFFIX "" 425 462 #endif 426 #define __cfaasm_label( label ) st atic struct asm_region label = \463 #define __cfaasm_label( label ) struct asm_region label = \ 427 464 ({ \ 428 465 struct asm_region region; \ … … 437 474 #ifdef __PIC__ 438 475 // Note that this works only for gcc 439 #define __cfaasm_label( label ) st atic struct asm_region label = \476 #define __cfaasm_label( label ) struct asm_region label = \ 440 477 ({ \ 441 478 struct asm_region region; \ … … 452 489 #error this is not the right thing to do 453 490 /* 454 #define __cfaasm_label( label ) st atic struct asm_region label = \491 #define __cfaasm_label( label ) struct asm_region label = \ 455 492 ({ \ 456 493 struct asm_region region; \ … … 479 516 __cfaasm_label( check ); 480 517 __cfaasm_label( dsable ); 518 __cfaasm_label( debug ); 481 519 482 520 // Check if preemption is safe … … 485 523 if( __cfaasm_in( ip, check ) ) { ready = false; goto EXIT; }; 486 524 if( __cfaasm_in( ip, dsable ) ) { ready = false; goto EXIT; }; 525 if( __cfaasm_in( ip, debug ) ) { ready = false; goto EXIT; }; 487 526 if( !__cfaabi_tls.preemption_state.enabled) { ready = false; goto EXIT; }; 488 527 if( __cfaabi_tls.preemption_state.in_progress ) { ready = false; goto EXIT; }; … … 536 575 // Wait for the preemption thread to finish 537 576 538 pthread_join( alarm_thread, 0p ); 539 free( alarm_stack ); 577 __destroy_pthread( alarm_thread, alarm_stack, 0p ); 540 578 541 579 // Preemption is now fully stopped … … 697 735 } 698 736 699 //=============================================================================================700 // Kernel Signal Debug701 //=============================================================================================702 703 void __cfaabi_check_preemption() {704 bool ready = __preemption_enabled();705 if(!ready) { abort("Preemption should be ready"); }706 707 sigset_t oldset;708 int ret;709 ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset); // workaround trac#208: cast should be unnecessary710 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }711 712 ret = sigismember(&oldset, SIGUSR1);713 if(ret < 0) { abort("ERROR sigismember returned %d", ret); }714 if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }715 716 ret = sigismember(&oldset, SIGALRM);717 if(ret < 0) { abort("ERROR sigismember returned %d", ret); }718 if(ret == 0) { abort("ERROR SIGALRM is enabled"); }719 720 ret = sigismember(&oldset, SIGTERM);721 if(ret < 0) { abort("ERROR sigismember returned %d", ret); }722 if(ret == 1) { abort("ERROR SIGTERM is disabled"); }723 }724 725 #ifdef __CFA_WITH_VERIFY__726 bool __cfaabi_dbg_in_kernel() {727 return !__preemption_enabled();728 }729 #endif730 731 737 // Local Variables: // 732 738 // mode: c //
Note: See TracChangeset
for help on using the changeset viewer.