Ignore:
Timestamp:
Dec 3, 2018, 12:17:35 PM (3 years ago)
Author:
alain
Message:

Improve the FAT32 file system to support cat, rm, cp commands.

File:
1 edited

Legend:

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

    r600 r603  
    5252
    5353    remote_busylock_init( XPTR( lock_cxy , &lock_ptr->lock ) , type );
     54
     55#if DEBUG_RWLOCK
     56thread_t * this = CURRENT_THREAD;
     57if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     58printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
     59__FUNCTION__, this->process->pid, this->trdid,
     60lock_type_str[type], local_cxy, lock_ptr );
     61#endif
     62
    5463}
    5564
     
    8594#if DEBUG_RWLOCK
    8695if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    87 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x]\n",
     96printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    8897__FUNCTION__, this->process->pid, this->trdid,
    89 lock_type_str[lock_type], lock_cxy, lock_ptr );
     98lock_type_str[lock_type], lock_cxy, lock_ptr,
     99hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
    90100#endif
    91101        // get pointer on calling thread
     
    108118    }
    109119
    110 #if DEBUG_RWLOCK
    111 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    112 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x]\n",
    113 __FUNCTION__, this->process->pid, this->trdid,
    114 lock_type_str[lock_type], lock_cxy, lock_ptr );
    115 #endif
    116 
    117120    // increment number of readers
    118121    hal_remote_atomic_add( count_xp , 1 );
     122
     123    hal_fence();
     124
     125#if DEBUG_RWLOCK
     126if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     127printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken = %d / count = %d\n",
     128__FUNCTION__, this->process->pid, this->trdid,
     129lock_type_str[lock_type], lock_cxy, lock_ptr,
     130hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     131#endif
    119132
    120133    // release busylock
     
    154167#if DEBUG_RWLOCK
    155168if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    156 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x]\n",
     169printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    157170__FUNCTION__, this->process->pid, this->trdid,
    158 lock_type_str[lock_type], lock_cxy, lock_ptr );
    159 #endif
     171lock_type_str[lock_type], lock_cxy, lock_ptr,
     172hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     173#endif
     174
    160175        // get local pointer on calling thread
    161176        thread_t * this = CURRENT_THREAD;
     
    177192    }
    178193
    179 #if DEBUG_RWLOCK
    180 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    181 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x]\n",
     194    // take rwlock for write
     195    hal_remote_s32( taken_xp , 1 );
     196
     197#if DEBUG_RWLOCK
     198if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     199printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
    182200__FUNCTION__, this->process->pid, this->trdid,
    183 lock_type_str[lock_type], lock_cxy, lock_ptr );
    184 #endif
    185 
    186     // take rwlock
    187     hal_remote_s32( taken_xp , 1 );
     201lock_type_str[lock_type], lock_cxy, lock_ptr,
     202hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     203#endif
    188204
    189205    // release busylock
     
    212228    remote_busylock_acquire( busylock_xp );
    213229
     230        // decrement number of readers
     231    hal_remote_atomic_add( count_xp , -1 );
     232
    214233#if DEBUG_RWLOCK
    215234thread_t * this      = CURRENT_THREAD;
    216235uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
    217 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    218 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x]\n",
     236xptr_t     taken_xp  = XPTR( lock_cxy , &lock_ptr->taken );
     237if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     238printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    219239__FUNCTION__, this->process->pid, this->trdid,
    220 lock_type_str[lock_type], lock_cxy, lock_ptr );
    221 #endif
    222 
    223         // decrement number of readers
    224     hal_remote_atomic_add( count_xp , -1 );
     240lock_type_str[lock_type], lock_cxy, lock_ptr,
     241hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     242#endif
    225243
    226244    // release first writer in waiting queue if no current readers
     
    309327    remote_busylock_acquire( busylock_xp );
    310328
     329    // release rwlock
     330    hal_remote_s32( taken_xp , 0 );
     331
    311332#if DEBUG_RWLOCK
    312333thread_t * this      = CURRENT_THREAD;
    313334uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
    314 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    315 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x]\n",
     335xptr_t     count_xp  = XPTR( lock_cxy , &lock_ptr->count );
     336if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     337printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    316338__FUNCTION__, this->process->pid, this->trdid,
    317 lock_type_str[lock_type], lock_cxy, lock_ptr );
    318 #endif
    319 
    320     // release rwlock
    321     hal_remote_s32( taken_xp , 0 );
     339lock_type_str[lock_type], lock_cxy, lock_ptr,
     340hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     341#endif
    322342
    323343    // unblock first waiting writer thread if writers waiting queue non empty
Note: See TracChangeset for help on using the changeset viewer.