Ignore:
Timestamp:
Aug 4, 2017, 4:22:27 PM (7 years ago)
Author:
alain
Message:

Bug fix : we don't need an atomic access to update the thread.remote_locks counter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/remote_rwlock.c

    r124 r318  
    5454
    5555    // get cluster and local pointer on local thread
    56     cxy_t               thread_cxy = local_cxy;
    57     thread_t          * thread_ptr = CURRENT_THREAD;
    58 
    59     // extended pointers on ticket, current, count, and thread->remote_locks
     56    thread_t          * thread_ptr = CURRENT_THREAD;
     57
     58    // extended pointers on ticket, current, count
    6059    xptr_t              ticket_xp  = XPTR( lock_cxy   , &lock_ptr->ticket );
    6160    xptr_t              current_xp = XPTR( lock_cxy   , &lock_ptr->current );
    6261    xptr_t              count_xp   = XPTR( lock_cxy   , &lock_ptr->count );
    63     xptr_t              locks_xp   = XPTR( thread_cxy , &thread_ptr->remote_locks );
    6462
    6563    // disable interrupts
     
    7775    ////////// From here we have the lock  ////////////
    7876
    79     // increment count and thead.remote_locks
     77    // increment count
    8078    hal_remote_atomic_add( count_xp , 1 );
    81     hal_remote_atomic_add( locks_xp , 1 );
     79
     80    // increment thread.remote_locks
     81    thread_ptr->remote_locks++;
    8282
    8383    // sync
     
    102102
    103103    // get cluster and local pointer on local thread
    104     cxy_t               thread_cxy = local_cxy;
    105     thread_t          * thread_ptr = CURRENT_THREAD;
    106 
    107     // extended pointers on lock->count and thread->remote_locks
     104    thread_t          * thread_ptr = CURRENT_THREAD;
     105
     106    // extended pointers on lock->count
    108107    xptr_t              count_xp = XPTR( lock_cxy   , &lock_ptr->count );
    109     xptr_t              locks_xp = XPTR( thread_cxy , &thread_ptr->remote_locks );
    110108
    111109    // disable interrupts
    112110        hal_disable_irq( &mode );
    113111 
    114     // decrement count and thread.remote_locks
     112    // decrement count
    115113    hal_remote_atomic_add( count_xp , -1 );
    116         hal_remote_atomic_add( locks_xp , -1 );
     114
     115    // decrement thread.remote_locks
     116        thread_ptr->remote_locks--;
    117117
    118118    // enable interrupts
     
    135135    thread_t          * thread_ptr = CURRENT_THREAD;
    136136
    137     // compute extended pointers on lock->ticket, lock->owner, and thread->remote_locks
     137    // compute extended pointers on lock->ticket, lock->owner
    138138    xptr_t              ticket_xp  = XPTR( lock_cxy   , &lock_ptr->ticket );
    139139    xptr_t              count_xp   = XPTR( lock_cxy   , &lock_ptr->count );
    140140    xptr_t              current_xp = XPTR( lock_cxy   , &lock_ptr->current );
    141141    xptr_t              owner_xp   = XPTR( lock_cxy   , &lock_ptr->owner );
    142     xptr_t              locks_xp   = XPTR( thread_cxy , &thread_ptr->remote_locks );
    143142    xptr_t              thread_xp  = XPTR( thread_cxy , thread_ptr );
    144143
     
    163162    }
    164163
    165     // register owner thread and increment thread.remote_locks
     164    // register owner thread
    166165    hal_remote_swd( owner_xp , thread_xp );
    167     hal_remote_atomic_add( locks_xp , 1 );
     166
     167    // increment thread.remote_locks
     168    thread_ptr->remote_locks++;
    168169
    169170    // enable interrupts
     
    182183
    183184    // get cluster and local pointer on local thread
    184     cxy_t               thread_cxy = local_cxy;
    185     thread_t          * thread_ptr = CURRENT_THREAD;
    186 
    187     // compute extended pointers on lock->ticket, lock->owner and thread->remote_locks
     185    thread_t          * thread_ptr = CURRENT_THREAD;
     186
     187    // compute extended pointers on lock->ticket, lock->owner
    188188    xptr_t              current_xp = XPTR( lock_cxy   , &lock_ptr->current );
    189189    xptr_t              owner_xp   = XPTR( lock_cxy   , &lock_ptr->owner );
    190     xptr_t              locks_xp   = XPTR( thread_cxy , &thread_ptr->remote_locks );
    191190
    192191    // disable interrupts
     
    196195    hal_remote_swd( owner_xp , XPTR_NULL );
    197196    hal_remote_atomic_add( current_xp , 1 );
    198         hal_remote_atomic_add( locks_xp , -1 );
     197
     198    // decrement thread.remote_locks
     199        thread_ptr->remote_locks--;
    199200
    200201    // enable interrupts
Note: See TracChangeset for help on using the changeset viewer.