- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel.cfa (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r24e321c r445f984 341 341 } 342 342 343 __STATS( if(this->print_halts) __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 0\n", this->unique_id, rdtscl()); )343 __STATS( if(this->print_halts) __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 0\n", this->unique_id, rdtscl()); ) 344 344 __cfadbg_print_safe(runtime_core, "Kernel : core %p waiting on eventfd %d\n", this, this->idle); 345 345 346 { 347 eventfd_t val; 348 ssize_t ret = read( this->idle, &val, sizeof(val) ); 349 if(ret < 0) { 350 switch((int)errno) { 351 case EAGAIN: 352 #if EAGAIN != EWOULDBLOCK 353 case EWOULDBLOCK: 354 #endif 355 case EINTR: 356 // No need to do anything special here, just assume it's a legitimate wake-up 357 break; 358 default: 359 abort( "KERNEL : internal error, read failure on idle eventfd, error(%d) %s.", (int)errno, strerror( (int)errno ) ); 360 } 361 } 362 } 346 // __disable_interrupts_hard(); 347 eventfd_t val; 348 eventfd_read( this->idle, &val ); 349 // __enable_interrupts_hard(); 363 350 364 351 __STATS( if(this->print_halts) __cfaabi_bits_print_safe( STDOUT_FILENO, "PH:%d - %lld 1\n", this->unique_id, rdtscl()); ) … … 422 409 /* paranoid */ verifyf( thrd_dst->link.next == 0p, "Expected null got %p", thrd_dst->link.next ); 423 410 __builtin_prefetch( thrd_dst->context.SP ); 411 412 int curr = __kernel_getcpu(); 413 if(thrd_dst->last_cpu != curr) { 414 int64_t l = thrd_dst->last_cpu; 415 int64_t c = curr; 416 int64_t v = (l << 32) | c; 417 __push_stat( __tls_stats(), v, false, "Processor", this ); 418 } 419 420 thrd_dst->last_cpu = curr; 424 421 425 422 __cfadbg_print_safe(runtime_core, "Kernel : core %p running thread %p (%s)\n", this, thrd_dst, thrd_dst->self_cor.name); … … 476 473 if(unlikely(thrd_dst->preempted != __NO_PREEMPTION)) { 477 474 // The thread was preempted, reschedule it and reset the flag 478 schedule_thread$( thrd_dst , UNPARK_LOCAL);475 schedule_thread$( thrd_dst ); 479 476 break RUNNING; 480 477 } … … 560 557 // Scheduler routines 561 558 // KERNEL ONLY 562 static void __schedule_thread( thread$ * thrd , unpark_hint hint) {559 static void __schedule_thread( thread$ * thrd ) { 563 560 /* paranoid */ verify( ! __preemption_enabled() ); 564 561 /* paranoid */ verify( ready_schedule_islocked()); … … 580 577 // Dereference the thread now because once we push it, there is not guaranteed it's still valid. 581 578 struct cluster * cl = thrd->curr_cluster; 582 __STATS(bool outside = hint == UNPARK_LOCAL &&thrd->last_proc && thrd->last_proc != kernelTLS().this_processor; )579 __STATS(bool outside = thrd->last_proc && thrd->last_proc != kernelTLS().this_processor; ) 583 580 584 581 // push the thread to the cluster ready-queue 585 push( cl, thrd, hint);582 push( cl, thrd, local ); 586 583 587 584 // variable thrd is no longer safe to use … … 608 605 } 609 606 610 void schedule_thread$( thread$ * thrd , unpark_hint hint) {607 void schedule_thread$( thread$ * thrd ) { 611 608 ready_schedule_lock(); 612 __schedule_thread( thrd , hint);609 __schedule_thread( thrd ); 613 610 ready_schedule_unlock(); 614 611 } … … 661 658 } 662 659 663 void __kernel_unpark( thread$ * thrd , unpark_hint hint) {660 void __kernel_unpark( thread$ * thrd ) { 664 661 /* paranoid */ verify( ! __preemption_enabled() ); 665 662 /* paranoid */ verify( ready_schedule_islocked()); … … 669 666 if(__must_unpark(thrd)) { 670 667 // Wake lost the race, 671 __schedule_thread( thrd , hint);668 __schedule_thread( thrd ); 672 669 } 673 670 … … 676 673 } 677 674 678 void unpark( thread$ * thrd , unpark_hint hint) {675 void unpark( thread$ * thrd ) { 679 676 if( !thrd ) return; 680 677 … … 682 679 disable_interrupts(); 683 680 // Wake lost the race, 684 schedule_thread$( thrd , hint);681 schedule_thread$( thrd ); 685 682 enable_interrupts(false); 686 683 }
Note:
See TracChangeset
for help on using the changeset viewer.