Ignore:
Timestamp:
Nov 10, 2017, 11:41:35 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
20ffcf3, 403b388, 490db327
Parents:
3edc2df (diff), 34c6c76 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/kernel.c

    r3edc2df r6d2386e  
    242242void finishRunning(processor * this) {
    243243        if( this->finish.action_code == Release ) {
    244                 unlock( this->finish.lock );
     244                unlock( *this->finish.lock );
    245245        }
    246246        else if( this->finish.action_code == Schedule ) {
     
    248248        }
    249249        else if( this->finish.action_code == Release_Schedule ) {
    250                 unlock( this->finish.lock );
     250                unlock( *this->finish.lock );
    251251                ScheduleThread( this->finish.thrd );
    252252        }
    253253        else if( this->finish.action_code == Release_Multi ) {
    254254                for(int i = 0; i < this->finish.lock_count; i++) {
    255                         unlock( this->finish.locks[i] );
     255                        unlock( *this->finish.locks[i] );
    256256                }
    257257        }
    258258        else if( this->finish.action_code == Release_Multi_Schedule ) {
    259259                for(int i = 0; i < this->finish.lock_count; i++) {
    260                         unlock( this->finish.locks[i] );
     260                        unlock( *this->finish.locks[i] );
    261261                }
    262262                for(int i = 0; i < this->finish.thrd_count; i++) {
     
    334334        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    335335
    336         lock(   &this_processor->cltr->ready_queue_lock DEBUG_CTX2 );
     336        lock(   this_processor->cltr->ready_queue_lock DEBUG_CTX2 );
    337337        append( this_processor->cltr->ready_queue, thrd );
    338         unlock( &this_processor->cltr->ready_queue_lock );
     338        unlock( this_processor->cltr->ready_queue_lock );
    339339
    340340        verify( disable_preempt_count > 0 );
     
    343343thread_desc * nextThread(cluster * this) {
    344344        verify( disable_preempt_count > 0 );
    345         lock( &this->ready_queue_lock DEBUG_CTX2 );
     345        lock( this->ready_queue_lock DEBUG_CTX2 );
    346346        thread_desc * head = pop_head( this->ready_queue );
    347         unlock( &this->ready_queue_lock );
     347        unlock( this->ready_queue_lock );
    348348        verify( disable_preempt_count > 0 );
    349349        return head;
     
    358358}
    359359
    360 void BlockInternal( spinlock * lock ) {
     360void BlockInternal( __spinlock_t * lock ) {
    361361        disable_interrupts();
    362362        this_processor->finish.action_code = Release;
     
    384384}
    385385
    386 void BlockInternal( spinlock * lock, thread_desc * thrd ) {
     386void BlockInternal( __spinlock_t * lock, thread_desc * thrd ) {
    387387        assert(thrd);
    388388        disable_interrupts();
     
    398398}
    399399
    400 void BlockInternal(spinlock * locks [], unsigned short count) {
     400void BlockInternal(__spinlock_t * locks [], unsigned short count) {
    401401        disable_interrupts();
    402402        this_processor->finish.action_code = Release_Multi;
     
    411411}
    412412
    413 void BlockInternal(spinlock * locks [], unsigned short lock_count, thread_desc * thrds [], unsigned short thrd_count) {
     413void BlockInternal(__spinlock_t * locks [], unsigned short lock_count, thread_desc * thrds [], unsigned short thrd_count) {
    414414        disable_interrupts();
    415415        this_processor->finish.action_code = Release_Multi_Schedule;
     
    426426}
    427427
    428 void LeaveThread(spinlock * lock, thread_desc * thrd) {
     428void LeaveThread(__spinlock_t * lock, thread_desc * thrd) {
    429429        verify( disable_preempt_count > 0 );
    430430        this_processor->finish.action_code = thrd ? Release_Schedule : Release;
     
    516516}
    517517
    518 static spinlock kernel_abort_lock;
    519 static spinlock kernel_debug_lock;
     518static __spinlock_t kernel_abort_lock;
     519static __spinlock_t kernel_debug_lock;
    520520static bool kernel_abort_called = false;
    521521
     
    523523        // abort cannot be recursively entered by the same or different processors because all signal handlers return when
    524524        // the globalAbort flag is true.
    525         lock( &kernel_abort_lock DEBUG_CTX2 );
     525        lock( kernel_abort_lock DEBUG_CTX2 );
    526526
    527527        // first task to abort ?
    528528        if ( !kernel_abort_called ) {                   // not first task to abort ?
    529529                kernel_abort_called = true;
    530                 unlock( &kernel_abort_lock );
     530                unlock( kernel_abort_lock );
    531531        }
    532532        else {
    533                 unlock( &kernel_abort_lock );
     533                unlock( kernel_abort_lock );
    534534
    535535                sigset_t mask;
     
    561561extern "C" {
    562562        void __lib_debug_acquire() {
    563                 lock( &kernel_debug_lock DEBUG_CTX2 );
     563                lock( kernel_debug_lock DEBUG_CTX2 );
    564564        }
    565565
    566566        void __lib_debug_release() {
    567                 unlock( &kernel_debug_lock );
     567                unlock( kernel_debug_lock );
    568568        }
    569569}
     
    574574//-----------------------------------------------------------------------------
    575575// Locks
    576 void ?{}( spinlock & this ) {
    577         this.lock = 0;
    578 }
    579 void ^?{}( spinlock & this ) {
    580 
    581 }
    582 
    583 bool try_lock( spinlock * this DEBUG_CTX_PARAM2 ) {
    584         return this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0;
    585 }
    586 
    587 void lock( spinlock * this DEBUG_CTX_PARAM2 ) {
    588         for ( unsigned int i = 1;; i += 1 ) {
    589                 if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) { break; }
    590         }
    591         LIB_DEBUG_DO(
    592                 this->prev_name = caller;
    593                 this->prev_thrd = this_thread;
    594         )
    595 }
    596 
    597 void lock_yield( spinlock * this DEBUG_CTX_PARAM2 ) {
    598         for ( unsigned int i = 1;; i += 1 ) {
    599                 if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) { break; }
    600                 yield();
    601         }
    602         LIB_DEBUG_DO(
    603                 this->prev_name = caller;
    604                 this->prev_thrd = this_thread;
    605         )
    606 }
    607 
    608 
    609 void unlock( spinlock * this ) {
    610         __sync_lock_release_4( &this->lock );
    611 }
    612 
    613576void  ?{}( semaphore & this, int count = 1 ) {
    614577        (this.lock){};
     
    619582
    620583void P(semaphore & this) {
    621         lock( &this.lock DEBUG_CTX2 );
     584        lock( this.lock DEBUG_CTX2 );
    622585        this.count -= 1;
    623586        if ( this.count < 0 ) {
     
    629592        }
    630593        else {
    631             unlock( &this.lock );
     594            unlock( this.lock );
    632595        }
    633596}
     
    635598void V(semaphore & this) {
    636599        thread_desc * thrd = NULL;
    637         lock( &this.lock DEBUG_CTX2 );
     600        lock( this.lock DEBUG_CTX2 );
    638601        this.count += 1;
    639602        if ( this.count <= 0 ) {
     
    642605        }
    643606
    644         unlock( &this.lock );
     607        unlock( this.lock );
    645608
    646609        // make new owner
Note: See TracChangeset for help on using the changeset viewer.