Changeset 563 for trunk/kernel/libk/htab.c
- Timestamp:
- Oct 4, 2018, 11:16:13 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/htab.c
r492 r563 26 26 #include <hal_special.h> 27 27 #include <htab.h> 28 #include < rwlock.h>28 #include <busylock.h> 29 29 #include <list.h> 30 30 #include <printk.h> 31 31 #include <vfs.h> 32 32 33 33 34 /////////////////////////////////////////////////////////////////////////////////////////// 34 35 // Item type specific (static) functions (two functions for each item type). … … 42 43 // @ return the index value, from 0 to (HASHTAB_SIZE - 1) 43 44 /////////////////////////////////////////////////////////////////////////////////////////// 44 45 45 static uint32_t htab_inode_index( void * key ) 46 46 { … … 59 59 // @ return pointer on item if found / return NULL if not found. 60 60 /////////////////////////////////////////////////////////////////////////////////////// 61 62 61 static void * htab_inode_scan( htab_t * htab, 63 62 uint32_t index, … … 88 87 89 88 // initialize readlock 90 rwlock_init( &htab->lock);89 busylock_init( &htab->lock , LOCK_HTAB_STATE ); 91 90 92 91 htab->items = 0; … … 117 116 uint32_t index = htab->index( key ); 118 117 119 // take the lock in write mode120 rwlock_wr_lock( &htab->lock );118 // take the lock 119 busylock_acquire( &htab->lock ); 121 120 122 121 // scan sub-list to check if item exist … … 126 125 { 127 126 // release lock 128 rwlock_wr_unlock( &htab->lock );129 130 return -1;127 busylock_release( &htab->lock ); 128 129 return 0xFFFFFFFF; 131 130 } 132 131 else // item doesn't exist => register … … 139 138 140 139 // release lock 141 rwlock_wr_unlock( &htab->lock );140 busylock_release( &htab->lock ); 142 141 143 142 return 0; … … 153 152 uint32_t index = htab->index( key ); 154 153 155 // take the lock in write mode156 rwlock_wr_lock( &htab->lock );154 // take the lock 155 busylock_acquire( &htab->lock ); 157 156 158 157 // scan sub-list to chek if item exist … … 162 161 { 163 162 // release lock 164 rwlock_wr_unlock( &htab->lock );165 166 return -1;163 busylock_release( &htab->lock ); 164 165 return 0xFFFFFFFF; 167 166 } 168 167 else // item exist => remove it … … 175 174 176 175 // release lock 177 rwlock_wr_unlock( &htab->lock );176 busylock_release( &htab->lock ); 178 177 179 178 return 0; … … 188 187 uint32_t index = htab->index( key ); 189 188 190 // take the lock in read mode191 rwlock_rd_lock( &htab->lock );189 // take the lock 190 busylock_acquire( &htab->lock ); 192 191 193 192 // scan sub-list … … 195 194 196 195 // release lock 197 rwlock_rd_unlock( &htab->lock );196 busylock_release( &htab->lock ); 198 197 199 198 return item;
Note: See TracChangeset
for help on using the changeset viewer.