Ignore:
Timestamp:
Dec 20, 2017, 4:51:09 PM (4 years ago)
Author:
alain
Message:

Fix bugs in exec

File:
1 edited

Legend:

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

    r337 r409  
    4040    hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->current ) , 0 );
    4141    hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->count )   , 0 );
     42
     43#if CONFIG_LOCKS_DEBUG
    4244    hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner )   , XPTR_NULL );
     45    xlist_entry_init( XPTR( lock_cxy , &lock_ptr->list ) );
     46#endif
     47
    4348}
    4449
     
    5358    cxy_t             lock_cxy = GET_CXY( lock_xp );
    5459
    55     // get cluster and local pointer on local thread
     60    // get local pointer on local thread
    5661    thread_t          * thread_ptr = CURRENT_THREAD;
    5762
     
    8186    thread_ptr->remote_locks++;
    8287
     88#if CONFIG_LOCKS_DEBUG
     89    xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     90                     XPTR( lock_cxy ,  &lock_ptr->list ) );
     91#endif
     92
    8393    // sync
    8494    hal_fence();
     
    115125    // decrement thread.remote_locks
    116126        thread_ptr->remote_locks--;
     127
     128#if CONFIG_LOCKS_DEBUG
     129    xlist_unlink( XPTR( lock_cxy , &lock->ptr->list ) );
     130#endif
    117131
    118132    // enable interrupts
     
    134148    cxy_t             lock_cxy = GET_CXY( lock_xp );
    135149
    136     // get cluster and local pointer on local thread
    137     cxy_t               thread_cxy = local_cxy;
     150    // get local pointer on local thread
    138151    thread_t          * thread_ptr = CURRENT_THREAD;
    139152
     
    142155    xptr_t              count_xp   = XPTR( lock_cxy   , &lock_ptr->count );
    143156    xptr_t              current_xp = XPTR( lock_cxy   , &lock_ptr->current );
    144     xptr_t              owner_xp   = XPTR( lock_cxy   , &lock_ptr->owner );
    145     xptr_t              thread_xp  = XPTR( thread_cxy , thread_ptr );
    146157
    147158    // disable interrupts
     
    165176    }
    166177
    167     // register owner thread
    168     hal_remote_swd( owner_xp , thread_xp );
     178#if CONFIG_LOCKS_DEBUG
     179    hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
     180                    XPTR( local_cxy , thread_ptr ) );
     181    xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     182                     XPTR( lock_cxy  , &lock_ptr->list ) );
     183#endif   
    169184
    170185    // increment thread.remote_locks
     
    188203    thread_t          * thread_ptr = CURRENT_THREAD;
    189204
    190     // compute extended pointers on lock->ticket, lock->owner
     205    // compute extended pointer on lock->ticket
    191206    xptr_t              current_xp = XPTR( lock_cxy   , &lock_ptr->current );
    192     xptr_t              owner_xp   = XPTR( lock_cxy   , &lock_ptr->owner );
    193207
    194208    // disable interrupts
    195209        hal_disable_irq( &mode );
    196210 
    197     // unregister owner thread, and release lock
    198     hal_remote_swd( owner_xp , XPTR_NULL );
     211#if CONFIG_LOCKS_OWNER
     212    hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
     213    xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     214#endif
     215
     216    // release lock
    199217    hal_remote_atomic_add( current_xp , 1 );
    200218
     
    217235    uint32_t     current;               // ticket index of current owner
    218236    uint32_t     count;                 // current number of reader threads
    219     xptr_t       owner;                 // extended pointer on writer thread
    220237
    221238    // get cluster and local pointer on remote_rwlock
     
    226243    current = hal_remote_lw ( XPTR( lock_cxy , &lock_ptr->current ) );
    227244    count   = hal_remote_lw ( XPTR( lock_cxy , &lock_ptr->count ) );
    228     owner   = hal_remote_lwd( XPTR( lock_cxy , &lock_ptr->owner ) );
    229 
    230     printk("\n*** rwlock <%l> %s : ticket = %d / current = %d / count = %d / owner = %l\n",
    231            lock_xp , comment , ticket , current , count , owner );
     245
     246    printk("\n*** rwlock <%l> %s : ticket = %d / current = %d / count = %d\n",
     247           lock_xp , comment , ticket , current , count );
    232248
    233249}  // end remote_rwlock_print()
Note: See TracChangeset for help on using the changeset viewer.