Changes in src/libcfa/concurrency/kernel.c [8fc45b7:6a5be52]
- File:
-
- 1 edited
-
src/libcfa/concurrency/kernel.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel.c
r8fc45b7 r6a5be52 158 158 LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", &this); 159 159 this.do_terminate = true; 160 P( this.terminated );160 P( &this.terminated ); 161 161 pthread_join( this.kernel_thread, NULL ); 162 162 } … … 216 216 } 217 217 218 V( this->terminated );218 V( &this->terminated ); 219 219 220 220 LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this); … … 335 335 336 336 lock( &this_processor->cltr->ready_queue_lock DEBUG_CTX2 ); 337 append( this_processor->cltr->ready_queue, thrd );337 append( &this_processor->cltr->ready_queue, thrd ); 338 338 unlock( &this_processor->cltr->ready_queue_lock ); 339 339 … … 344 344 verify( disable_preempt_count > 0 ); 345 345 lock( &this->ready_queue_lock DEBUG_CTX2 ); 346 thread_desc * head = pop_head( this->ready_queue );346 thread_desc * head = pop_head( &this->ready_queue ); 347 347 unlock( &this->ready_queue_lock ); 348 348 verify( disable_preempt_count > 0 ); … … 398 398 } 399 399 400 void BlockInternal(spinlock * locks [], unsigned short count) {400 void BlockInternal(spinlock ** locks, unsigned short count) { 401 401 disable_interrupts(); 402 402 this_processor->finish.action_code = Release_Multi; … … 411 411 } 412 412 413 void BlockInternal(spinlock * locks [], unsigned short lock_count, thread_desc * thrds [], unsigned short thrd_count) {413 void BlockInternal(spinlock ** locks, unsigned short lock_count, thread_desc ** thrds, unsigned short thrd_count) { 414 414 disable_interrupts(); 415 415 this_processor->finish.action_code = Release_Multi_Schedule; … … 618 618 void ^?{}(semaphore & this) {} 619 619 620 void P(semaphore &this) {621 lock( &this .lock DEBUG_CTX2 );622 this .count -= 1;623 if ( this .count < 0 ) {620 void P(semaphore * this) { 621 lock( &this->lock DEBUG_CTX2 ); 622 this->count -= 1; 623 if ( this->count < 0 ) { 624 624 // queue current task 625 append( this.waiting, (thread_desc *)this_thread );625 append( &this->waiting, (thread_desc *)this_thread ); 626 626 627 627 // atomically release spin lock and block 628 BlockInternal( &this .lock );628 BlockInternal( &this->lock ); 629 629 } 630 630 else { 631 unlock( &this .lock );632 } 633 } 634 635 void V(semaphore &this) {631 unlock( &this->lock ); 632 } 633 } 634 635 void V(semaphore * this) { 636 636 thread_desc * thrd = NULL; 637 lock( &this .lock DEBUG_CTX2 );638 this .count += 1;639 if ( this .count <= 0 ) {637 lock( &this->lock DEBUG_CTX2 ); 638 this->count += 1; 639 if ( this->count <= 0 ) { 640 640 // remove task at head of waiting list 641 thrd = pop_head( this.waiting );642 } 643 644 unlock( &this .lock );641 thrd = pop_head( &this->waiting ); 642 } 643 644 unlock( &this->lock ); 645 645 646 646 // make new owner … … 655 655 } 656 656 657 void append( __thread_queue_t &this, thread_desc * t ) {658 verify(this .tail != NULL);659 *this .tail = t;660 this .tail = &t->next;661 } 662 663 thread_desc * pop_head( __thread_queue_t &this ) {664 thread_desc * head = this .head;657 void append( __thread_queue_t * this, thread_desc * t ) { 658 verify(this->tail != NULL); 659 *this->tail = t; 660 this->tail = &t->next; 661 } 662 663 thread_desc * pop_head( __thread_queue_t * this ) { 664 thread_desc * head = this->head; 665 665 if( head ) { 666 this .head = head->next;666 this->head = head->next; 667 667 if( !head->next ) { 668 this .tail = &this.head;668 this->tail = &this->head; 669 669 } 670 670 head->next = NULL; … … 673 673 } 674 674 675 thread_desc * remove( __thread_queue_t &this, thread_desc ** it ) {675 thread_desc * remove( __thread_queue_t * this, thread_desc ** it ) { 676 676 thread_desc * thrd = *it; 677 677 verify( thrd ); … … 679 679 (*it) = thrd->next; 680 680 681 if( this .tail == &thrd->next ) {682 this .tail = it;681 if( this->tail == &thrd->next ) { 682 this->tail = it; 683 683 } 684 684 685 685 thrd->next = NULL; 686 686 687 verify( (this .head == NULL) == (&this.head == this.tail) );688 verify( *this .tail == NULL );687 verify( (this->head == NULL) == (&this->head == this->tail) ); 688 verify( *this->tail == NULL ); 689 689 return thrd; 690 690 } … … 694 694 } 695 695 696 void push( __condition_stack_t &this, __condition_criterion_t * t ) {696 void push( __condition_stack_t * this, __condition_criterion_t * t ) { 697 697 verify( !t->next ); 698 t->next = this .top;699 this .top = t;700 } 701 702 __condition_criterion_t * pop( __condition_stack_t &this ) {703 __condition_criterion_t * top = this .top;698 t->next = this->top; 699 this->top = t; 700 } 701 702 __condition_criterion_t * pop( __condition_stack_t * this ) { 703 __condition_criterion_t * top = this->top; 704 704 if( top ) { 705 this .top = top->next;705 this->top = top->next; 706 706 top->next = NULL; 707 707 }
Note:
See TracChangeset
for help on using the changeset viewer.