Changeset 22f94a4 for libcfa/src/concurrency/preemption.cfa
- Timestamp:
- Aug 11, 2020, 4:40:15 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 0d070ca
- Parents:
- 07d867b (diff), 129674b (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
-
libcfa/src/concurrency/preemption.cfa (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/preemption.cfa
r07d867b r22f94a4 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 5 16:34:05 201913 // Update Count : 4 312 // Last Modified On : Wed Jun 17 11:36:25 2020 13 // Update Count : 46 14 14 // 15 15 … … 19 19 #include <assert.h> 20 20 21 extern "C" {22 21 #include <errno.h> 23 22 #include <stdio.h> … … 25 24 #include <unistd.h> 26 25 #include <limits.h> // PTHREAD_STACK_MIN 27 }28 26 29 27 #include "bits/signal.hfa" 28 #include "kernel_private.hfa" 30 29 31 30 #if !defined(__CFA_DEFAULT_PREEMPTION__) … … 39 38 // FwdDeclarations : timeout handlers 40 39 static void preempt( processor * this ); 41 static void timeout( $thread * this );40 static void timeout( struct __processor_id_t * id, $thread * this ); 42 41 43 42 // FwdDeclarations : Signal handlers … … 90 89 91 90 // Tick one frame of the Discrete Event Simulation for alarms 92 static void tick_preemption( ) {91 static void tick_preemption( struct __processor_id_t * id ) { 93 92 alarm_node_t * node = 0p; // Used in the while loop but cannot be declared in the while condition 94 93 alarm_list_t * alarms = &event_kernel->alarms; // Local copy for ease of reading … … 108 107 } 109 108 else { 110 timeout( node->thrd );109 timeout( id, node->thrd ); 111 110 } 112 111 … … 121 120 // If there are still alarms pending, reset the timer 122 121 if( & (*alarms)`first ) { 123 __cfa abi_dbg_print_buffer_decl(" KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);122 __cfadbg_print_buffer_decl(preemption, " KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv); 124 123 Duration delta = (*alarms)`first.alarm - currtime; 125 124 Duration capped = max(delta, 50`us); … … 188 187 void enable_interrupts( __cfaabi_dbg_ctx_param ) { 189 188 processor * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic store 189 /* paranoid */ verify( proc ); 190 190 191 191 with( kernelTLS.preemption_state ){ … … 268 268 269 269 // reserved for future use 270 static void timeout( $thread * this ) { 271 __unpark( this __cfaabi_dbg_ctx2 ); 270 static void timeout( struct __processor_id_t * id, $thread * this ) { 271 #if !defined( __CFA_NO_STATISTICS__ ) 272 kernelTLS.this_stats = this->curr_cluster->stats; 273 #endif 274 __unpark( id, this __cfaabi_dbg_ctx2 ); 272 275 } 273 276 … … 291 294 // Startup routine to activate preemption 292 295 // Called from kernel_startup 293 void kernel_start_preemption() {296 void __kernel_alarm_startup() { 294 297 __cfaabi_dbg_print_safe( "Kernel : Starting preemption\n" ); 295 298 … … 313 316 // Shutdown routine to deactivate preemption 314 317 // Called from kernel_shutdown 315 void kernel_stop_preemption() {318 void __kernel_alarm_shutdown() { 316 319 __cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n" ); 317 320 … … 405 408 // Waits on SIGALRM and send SIGUSR1 to whom ever needs it 406 409 static void * alarm_loop( __attribute__((unused)) void * args ) { 410 __processor_id_t id; 411 id.id = doregister(&id); 412 407 413 // Block sigalrms to control when they arrive 408 414 sigset_t mask; … … 449 455 // __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n" ); 450 456 lock( event_kernel->lock __cfaabi_dbg_ctx2 ); 451 tick_preemption( );457 tick_preemption( &id ); 452 458 unlock( event_kernel->lock ); 453 459 break; … … 462 468 EXIT: 463 469 __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" ); 470 unregister(&id); 464 471 return 0p; 465 472 } … … 475 482 sigset_t oldset; 476 483 int ret; 477 ret = pthread_sigmask(0, 0p, &oldset);484 ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset); // workaround trac#208: cast should be unnecessary 478 485 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); } 479 486
Note:
See TracChangeset
for help on using the changeset viewer.