Ignore:
Timestamp:
Oct 4, 2018, 11:16:13 PM (3 years ago)
Author:
alain
Message:

Complete restructuration of kernel spinlocks.

File:
1 edited

Legend:

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

    r492 r563  
    2626#include <hal_special.h>
    2727#include <htab.h>
    28 #include <rwlock.h>
     28#include <busylock.h>
    2929#include <list.h>
    3030#include <printk.h>
    3131#include <vfs.h>
    3232
     33
    3334///////////////////////////////////////////////////////////////////////////////////////////
    3435//    Item type specific (static) functions (two functions for each item type).
     
    4243// @ return the index value, from 0 to (HASHTAB_SIZE - 1)
    4344///////////////////////////////////////////////////////////////////////////////////////////
    44 
    4545static uint32_t htab_inode_index( void * key )
    4646{
     
    5959// @ return pointer on item if found / return NULL if not found.
    6060///////////////////////////////////////////////////////////////////////////////////////
    61 
    6261static void * htab_inode_scan( htab_t  * htab,
    6362                               uint32_t  index,
     
    8887
    8988    // initialize readlock
    90     rwlock_init( &htab->lock );
     89    busylock_init( &htab->lock , LOCK_HTAB_STATE );
    9190
    9291    htab->items = 0;
     
    117116    uint32_t index = htab->index( key );
    118117
    119     // take the lock in write mode
    120     rwlock_wr_lock( &htab->lock );
     118    // take the lock
     119    busylock_acquire( &htab->lock );
    121120
    122121    // scan sub-list to check if item exist
     
    126125    {
    127126        // release lock
    128         rwlock_wr_unlock( &htab->lock );
    129 
    130         return -1;
     127        busylock_release( &htab->lock );
     128
     129        return 0xFFFFFFFF;
    131130    }
    132131    else               // item doesn't exist => register
     
    139138
    140139        // release lock
    141         rwlock_wr_unlock( &htab->lock );
     140        busylock_release( &htab->lock );
    142141
    143142        return 0;
     
    153152    uint32_t index = htab->index( key );
    154153
    155     // take the lock in write mode
    156     rwlock_wr_lock( &htab->lock );
     154    // take the lock
     155    busylock_acquire( &htab->lock );
    157156
    158157    // scan sub-list to chek if item exist
     
    162161    {
    163162        // release lock
    164         rwlock_wr_unlock( &htab->lock );
    165 
    166         return -1;
     163        busylock_release( &htab->lock );
     164
     165        return 0xFFFFFFFF;
    167166    }
    168167    else               // item exist => remove it
     
    175174
    176175        // release lock
    177         rwlock_wr_unlock( &htab->lock );
     176        busylock_release( &htab->lock );
    178177
    179178        return 0;
     
    188187    uint32_t index = htab->index( key );
    189188
    190     // take the lock in read mode
    191     rwlock_rd_lock( &htab->lock );
     189    // take the lock
     190    busylock_acquire( &htab->lock );
    192191
    193192    // scan sub-list
     
    195194
    196195    // release lock
    197     rwlock_rd_unlock( &htab->lock );
     196    busylock_release( &htab->lock );
    198197
    199198        return item;
Note: See TracChangeset for help on using the changeset viewer.