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

Fix bugs in exec

File:
1 edited

Legend:

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

    r408 r409  
    3838
    3939        hal_remote_sw ( XPTR( cxy , &ptr->taken ) , 0 );
     40
     41#if CONFIG_LOCKS_CONFIG
    4042        hal_remote_swd( XPTR( cxy , &ptr->owner ) , XPTR_NULL );
    4143        xlist_entry_init( XPTR( cxy , &ptr->list ) );
     44#endif
     45
    4246}
    4347
     
    5256        cxy_t               lock_cxy = GET_CXY( lock_xp );
    5357
    54         // get cluster and local pointer on local thread
    55         cxy_t               thread_cxy = local_cxy;
     58        // get local pointer on local thread
    5659        thread_t          * thread_ptr = CURRENT_THREAD;
    5760
     
    7376                thread_ptr->remote_locks++;
    7477
     78#if CONFIG_LOCKS_DEBUG
    7579                hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
    76                             (uint64_t)XPTR( thread_cxy , thread_ptr) );
    77 
    78                 xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
    79                              XPTR( lock_cxy , &lock_ptr->list ) );
     80                                XPTR( thread_cxy , thread_ptr) );
     81                xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     82                                 XPTR( lock_cxy , &lock_ptr->list ) );
     83#endif
    8084
    8185                hal_restore_irq(mode);
     
    96100        cxy_t               lock_cxy = GET_CXY( lock_xp );
    97101
    98         // get cluster and local pointer on local thread
    99         cxy_t               thread_cxy = local_cxy;
     102        // get local pointer on local thread
    100103        thread_t          * thread_ptr = CURRENT_THREAD;
    101104
     
    118121        thread_ptr->remote_locks++;
    119122
    120         hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
    121                         (uint64_t)XPTR( thread_cxy , thread_ptr) );
    122 
    123         xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
    124                          XPTR( lock_cxy , &lock_ptr->list ) );
     123#if CONFIG_LOCKS_DEBUG
     124        hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
     125                        XPTR( local_cxy , thread_ptr) );
     126        xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     127                         XPTR( lock_cxy  , &lock_ptr->list ) );
     128#endif
    125129
    126130        // irq_state must be restored when lock is released
     
    140144        thread_t          * thread_ptr = CURRENT_THREAD;
    141145
     146#if CONFIG_LOCKS_DEBUG
    142147        hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
     148        xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     149#endif
     150
    143151        hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->taken ) , 0 );
    144152        thread_ptr->remote_locks--;
    145         xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
    146153
    147154    // deschedule if pending request
     
    163170        cxy_t               lock_cxy = GET_CXY( lock_xp );
    164171
    165     // get cluster and local pointer on calling thread
    166     cxy_t               thread_cxy = local_cxy;
     172    // get local pointer on calling thread
    167173    thread_t          * thread_ptr = CURRENT_THREAD;
    168174
     
    191197        thread_ptr->remote_locks++;
    192198
    193         hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
    194                         (uint64_t)XPTR( thread_cxy , thread_ptr) );
    195 
    196         xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
    197                          XPTR( lock_cxy , &lock_ptr->list ) );
     199#if CONFIG_LOCKS_DEBUG
     200        hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
     201                        XPTR( local_cxy , thread_ptr) );
     202        xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     203                         XPTR( lock_cxy  , &lock_ptr->list ) );
     204#endif
    198205
    199206        // enable interrupts
     
    211218        thread_t          * thread_ptr = CURRENT_THREAD;
    212219
     220#if CONFIG_LOCKS_DEBUG
    213221        hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
     222        xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     223#endif
     224
    214225        hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->taken ) , 0 );
    215226        thread_ptr->remote_locks--;
    216         xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
    217227
    218228    // deschedule if pending request
     
    220230}
    221231
    222 //////////////////////////////////////////////
    223 xptr_t remote_spinlock_owner( xptr_t lock_xp )
    224 {
    225     // get cluster and local pointer on remote_spinlock
    226     remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
    227     cxy_t               lock_cxy = GET_CXY( lock_xp );
    228 
    229     return hal_remote_lw( XPTR( lock_cxy , &lock_ptr->owner ) );
    230 }
Note: See TracChangeset for help on using the changeset viewer.