Ignore:
Timestamp:
Dec 3, 2018, 12:17:35 PM (5 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/rwlock.c

    r600 r603  
    4949
    5050    busylock_init( &lock->lock , type );
     51
     52#if DEBUG_RWLOCK
     53thread_t * this = CURRENT_THREAD;
     54if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     55printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
     56__FUNCTION__, this->process->pid, this->trdid,
     57lock_type_str[type], local_cxy, lock );
     58#endif
     59
    5160}
    5261
     
    6877#if DEBUG_RWLOCK
    6978if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    70 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x]\n",
    71 __FUNCTION__, this->process->pid, this->trdid,
    72 lock_type_str[lock->lock.type], local_cxy, lock );
     79printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
     80__FUNCTION__, this->process->pid, this->trdid,
     81lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count );
    7382#endif
    7483        // register reader thread in waiting queue
     
    8897    }
    8998
    90 #if DEBUG_RWLOCK
    91 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    92 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x]\n",
    93 __FUNCTION__, this->process->pid, this->trdid,
    94 lock_type_str[lock->lock.type], local_cxy, lock );
    95 #endif
    96 
    9799    // increment number of readers
    98100    lock->count++;
     101
     102#if DEBUG_RWLOCK
     103if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     104printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
     105__FUNCTION__, this->process->pid, this->trdid,
     106lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count );
     107#endif
    99108
    100109    // release busylock
     
    120129#if DEBUG_RWLOCK
    121130if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    122 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x]\n",
    123 __FUNCTION__, this->process->pid, this->trdid,
    124 lock_type_str[lock->lock.type], local_cxy, lock );
     131printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
     132__FUNCTION__, this->process->pid, this->trdid,
     133lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count );
    125134#endif
    126135        // register writer in waiting queue
    127136        list_add_last( &lock->wr_root , &this->wait_list );
    128137
    129         // block reader thread
     138        // block writer thread
    130139        thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_LOCK );
    131140       
     
    140149    }
    141150
    142 #if DEBUG_RWLOCK
    143 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    144 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x]\n",
    145 __FUNCTION__, this->process->pid, this->trdid,
    146 lock_type_str[lock->lock.type], local_cxy, lock );
    147 #endif
    148 
    149151    // take the rwlock
    150152    lock->taken = 1;
     153
     154#if DEBUG_RWLOCK
     155if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     156printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
     157__FUNCTION__, this->process->pid, this->trdid,
     158lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count );
     159#endif
    151160
    152161    // release busylock
     
    164173    busylock_acquire( &lock->lock );
    165174
    166 #if DEBUG_RWLOCK
    167 thread_t * this = CURRENT_THREAD;
    168 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    169 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x]\n",
    170 __FUNCTION__, this->process->pid, this->trdid,
    171 lock_type_str[lock->lock.type], local_cxy, lock );
    172 #endif
    173 
    174175    // decrement number of readers
    175176    lock->count--;
     177
     178#if DEBUG_RWLOCK
     179thread_t * this = CURRENT_THREAD;
     180if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     181printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
     182__FUNCTION__, this->process->pid, this->trdid,
     183lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count );
     184#endif
    176185
    177186    // release first writer in waiting queue if no current readers
     
    233242    busylock_acquire( &lock->lock );
    234243
    235 #if DEBUG_RWLOCK
    236 thread_t * this = CURRENT_THREAD;
    237 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
    238 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x]\n",
    239 __FUNCTION__, this->process->pid, this->trdid,
    240 lock_type_str[lock->lock.type], local_cxy, lock );
    241 #endif
    242 
    243244    // release the rwlock
    244245    lock->taken = 0;
     246
     247#if DEBUG_RWLOCK
     248thread_t * this = CURRENT_THREAD;
     249if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )
     250printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
     251__FUNCTION__, this->process->pid, this->trdid,
     252lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count );
     253#endif
    245254
    246255    // release first waiting writer thread if writers waiting queue non empty
Note: See TracChangeset for help on using the changeset viewer.