Changeset 610 for trunk/kernel/libk
- Timestamp:
- Dec 27, 2018, 7:38:58 PM (6 years ago)
- Location:
- trunk/kernel/libk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/grdxt.c
r603 r610 133 133 void ** ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) ); 134 134 135 printk("\n***** Generic Radix Tree for <%s> : %d / %d / %d\n", 136 name, 1<<w1 , 1<<w2 , 1<<w3 ); 135 printk("\n***** Generic Radix Tree for <%s>\n", name ); 137 136 138 137 for( ix1=0 ; ix1 < (uint32_t)(1<<w1) ; ix1++ ) … … 327 326 328 327 // get ptr1 329 void 328 void ** ptr1 = hal_remote_lpt( XPTR( rt_cxy , &rt_ptr->root ) ); 330 329 331 330 // get ptr2 332 void 331 void ** ptr2 = hal_remote_lpt( XPTR( rt_cxy , &ptr1[ix1] ) ); 333 332 if( ptr2 == NULL ) return XPTR_NULL; 334 333 335 334 // get ptr3 336 void 335 void ** ptr3 = hal_remote_lpt( XPTR( rt_cxy , &ptr2[ix2] ) ); 337 336 if( ptr3 == NULL ) return XPTR_NULL; 338 337 339 // get value 340 xptr_t value = XPTR( rt_cxy , ptr3[ix3] ); 341 342 return value; 338 // get pointer on registered item 339 void * item_ptr = hal_remote_lpt( XPTR( rt_cxy , &ptr3[ix3] ) ); 340 341 // return extended pointer on registered item 342 if ( item_ptr == NULL ) return XPTR_NULL; 343 else return XPTR( rt_cxy , item_ptr ); 343 344 344 345 } // end grdxt_remote_lookup() -
trunk/kernel/libk/grdxt.h
r603 r610 40 40 * - Lookup can be done by a thread running in any cluster (local or remote). 41 41 ****************************************************************************************** 42 * It is used by the mapper implementing the file cache:42 * When it is used by the mapper implementing the file cache: 43 43 * - the key is the page index in file. 44 44 * - the registered value is a local pointer on the page descriptor. -
trunk/kernel/libk/htab.c
r563 r610 34 34 /////////////////////////////////////////////////////////////////////////////////////////// 35 35 // Item type specific (static) functions (two functions for each item type). 36 // Example below if for <vhs_inode_t>, where the identifier is the inum field. 37 /////////////////////////////////////////////////////////////////////////////////////////// 38 39 /////////////////////////////////////////////////////////////////////////////////////////// 40 // These static functions compute the hash index from the key. 36 // Example below if for <bloup_t> type, where the identifier is an uint32_t field. 37 /////////////////////////////////////////////////////////////////////////////////////////// 38 39 typedef struct bloup_s 40 { 41 uint32_t key; 42 list_entry_t list; 43 } 44 bloup_t; 45 46 /////////////////////////////////////////////////////////////////////////////////////////// 47 // This static function computes the hash index from the key. 41 48 /////////////////////////////////////////////////////////////////////////////////////////// 42 49 // @ key : local pointer on key. 43 50 // @ return the index value, from 0 to (HASHTAB_SIZE - 1) 44 51 /////////////////////////////////////////////////////////////////////////////////////////// 45 static uint32_t htab_inode_index( void * key ) 46 { 47 uint32_t * inum = key; 48 return (((*inum) >> 16) ^ ((*inum) & 0xFFFF)) % HASHTAB_SIZE; 52 static uint32_t htab_bloup_index( void * key ) 53 { 54 return (*(uint32_t *)key) % HASHTAB_SIZE; 49 55 } 50 56 51 57 /////////////////////////////////////////////////////////////////////////////////////// 52 // Th ese static functions areused by htab_lookup(), htab_insert(), and htab_remove().58 // This static function is used by htab_lookup(), htab_insert(), and htab_remove(). 53 59 // They scan one sub-list identified by <index> to find an item identified by <key>. 54 60 // The sub-list is not modified, but the lock must have been taken by the caller. … … 59 65 // @ return pointer on item if found / return NULL if not found. 60 66 /////////////////////////////////////////////////////////////////////////////////////// 61 static void * htab_ inode_scan( htab_t * htab,67 static void * htab_bloup_scan( htab_t * htab, 62 68 uint32_t index, 63 69 void * key ) 64 70 { 65 71 list_entry_t * list_entry; // pointer on list_entry_t (iterator) 66 vfs_inode_t * inode; // pointer on item72 bloup_t * bloup; // pointer on item 67 73 68 74 LIST_FOREACH( &htab->roots[index] , list_entry ) 69 75 { 70 inode = (vfs_inode_t *)LIST_ELEMENT( list_entry , vfs_inode_t , list );71 if( inode->inum == *(uint32_t *)key ) return inode;76 bloup = (bloup_t *)LIST_ELEMENT( list_entry , bloup_t , list ); 77 if( bloup->key == *(uint32_t *)key ) return bloup; 72 78 } 73 79 … … 91 97 htab->items = 0; 92 98 93 if( type == HTAB_ INODE_TYPE )94 { 95 htab->scan = &htab_ inode_scan;96 htab->index = &htab_ inode_index;99 if( type == HTAB_BLOUP_TYPE ) 100 { 101 htab->scan = &htab_bloup_scan; 102 htab->index = &htab_bloup_index; 97 103 } 98 104 else -
trunk/kernel/libk/htab.h
r563 r610 31 31 32 32 ///////////////////////////////////////////////////////////////////////////////////////// 33 // This file define a generic, embedded, hash table.33 // This file define a generic, embedded, local hash table. 34 34 // 35 35 // It can only be accessed by threads running in the local cluster. … … 70 70 typedef enum 71 71 { 72 HTAB_ INODE_TYPE = 1, /*! item is a vfs_inode_t*/72 HTAB_BLOUP_TYPE = 1, /*! item is a bloup_t */ 73 73 } 74 74 htab_item_type_t; -
trunk/kernel/libk/list.h
r457 r610 3 3 * 4 4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012) 5 * Alain Greiner (2016 )5 * Alain Greiner (2016,2017,2018) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 23 23 */ 24 24 25 #ifndef _ ALMOS_LIST_H_26 #define _ ALMOS_LIST_H_25 #ifndef _LIST_H_ 26 #define _LIST_H_ 27 27 28 28 #include <kernel_config.h> 29 29 #include <hal_kernel_types.h> 30 #include <printk.h> 30 31 31 32 #ifndef NULL … … 240 241 } 241 242 242 243 #endif /* _ALMOS_LIST_H_ */ 243 /*************************************************************************** 244 * This debug function displays all entries of a list. 245 * @ root : local pointer on the root list_entry_t. 246 * @ string : list identifier displayed in header. 247 * @ max : max number of éléments to display. 248 **************************************************************************/ 249 static inline void list_display( list_entry_t * root, 250 char * string, 251 uint32_t max ) 252 { 253 list_entry_t * iter; 254 list_entry_t * next; 255 list_entry_t * pred; 256 uint32_t index; 257 258 next = root->next; 259 pred = root->pred; 260 261 printk("\n***** root (%x) / next (%x) / pred (%x) / %s *****\n", 262 root, next, pred, string ); 263 264 if( list_is_empty( root ) == false ) 265 { 266 for( iter = next , index = 0 ; 267 (iter != root) && (index < max) ; 268 iter = next , index++ ) 269 { 270 next = iter->next; 271 pred = iter->pred; 272 273 printk(" - %d : iter (%x) / next (%x) / pred (%x)\n", 274 index, iter, next, pred ); 275 } 276 } 277 } // end list_display() 278 279 280 #endif /* _LIST_H_ */ -
trunk/kernel/libk/queuelock.c
r603 r610 45 45 busylock_init( &lock->lock , type ); 46 46 47 #if DEBUG_QUEUELOCK 47 #if DEBUG_QUEUELOCK_TYPE 48 48 thread_t * this = CURRENT_THREAD; 49 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())49 if( DEBUG_QUEUELOCK_TYPE == type ) 50 50 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 51 51 __FUNCTION__, this->process->pid, this->trdid, … … 70 70 { 71 71 72 #if DEBUG_QUEUELOCK 73 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles() ) 72 #if DEBUG_QUEUELOCK_TYPE 73 uint32_t lock_type = lock->lock.type; 74 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 74 75 printk("\n[%s ] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n", 75 76 __FUNCTION__, this->process->pid, this->trdid, 76 lock_type_str[lock ->lock.type], local_cxy, lock );77 lock_type_str[lock_type], local_cxy, lock ); 77 78 #endif 78 79 // get pointer on calling thread … … 95 96 } 96 97 97 #if DEBUG_QUEUELOCK 98 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())98 #if DEBUG_QUEUELOCK_TYPE 99 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 99 100 printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n", 100 101 __FUNCTION__, this->process->pid, this->trdid, 101 lock_type_str[lock ->lock.type], local_cxy, lock );102 lock_type_str[lock_type], local_cxy, lock ); 102 103 #endif 103 104 … … 119 120 busylock_acquire( &lock->lock ); 120 121 121 #if DEBUG_QUEUELOCK 122 thread_t * this = CURRENT_THREAD; 123 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles() ) 122 #if DEBUG_QUEUELOCK_TYPE 123 uint32_t lock_type = lock->lock.type; 124 thread_t * this = CURRENT_THREAD; 125 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 124 126 printk("\n[%s] thread[%x,%x] RELEASE q_lock %s [%x,%x]\n", 125 127 __FUNCTION__, this->process->pid, this->trdid, 126 lock_type_str[lock ->lock.type], local_cxy, lock );128 lock_type_str[lock_type], local_cxy, lock ); 127 129 #endif 128 130 … … 136 138 thread_t * thread = LIST_FIRST( &lock->root , thread_t , wait_list ); 137 139 138 #if DEBUG_QUEUELOCK 139 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())140 #if DEBUG_QUEUELOCK_TYPE 141 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 140 142 printk("\n[%s] thread[%x,%x] UNBLOCK thread [%x,%x] / q_lock %s [%x,%x]\n", 141 143 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, 142 lock_type_str[lock ->lock.type], local_cxy, lock );144 lock_type_str[lock_type], local_cxy, lock ); 143 145 #endif 144 146 // remove this waiting thread from waiting list -
trunk/kernel/libk/remote_queuelock.c
r603 r610 54 54 remote_busylock_init( XPTR( lock_cxy , &lock_ptr->lock ) , type ); 55 55 56 #if DEBUG_QUEUELOCK 56 #if DEBUG_QUEUELOCK_TYPE 57 57 thread_t * this = CURRENT_THREAD; 58 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())58 if( DEBUG_QUEUELOCK_TYPE == type ) 59 59 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 60 60 __FUNCTION__, this->process->pid, this->trdid, … … 76 76 remote_queuelock_t * lock_ptr = GET_PTR( lock_xp ); 77 77 78 #if DEBUG_QUEUELOCK 78 #if DEBUG_QUEUELOCK_TYPE 79 79 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 80 80 #endif … … 90 90 { 91 91 92 #if DEBUG_QUEUELOCK 93 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())92 #if DEBUG_QUEUELOCK_TYPE 93 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 94 94 printk("\n[%s] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n", 95 95 __FUNCTION__, this->process->pid, this->trdid, … … 116 116 } 117 117 118 #if DEBUG_QUEUELOCK 119 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())118 #if DEBUG_QUEUELOCK_TYPE 119 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 120 120 printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n", 121 121 __FUNCTION__, this->process->pid, this->trdid, … … 128 128 // release busylock 129 129 remote_busylock_release( busylock_xp ); 130 131 hal_fence(); 130 132 131 133 } // end remote_queuelock_acquire() … … 147 149 remote_busylock_acquire( busylock_xp ); 148 150 149 #if DEBUG_QUEUELOCK 151 #if DEBUG_QUEUELOCK_TYPE 150 152 thread_t * this = CURRENT_THREAD; 151 153 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 152 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())154 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 153 155 printk("\n[%s] thread[%x,%x] RELEASE q_lock %s (%x,%x)\n", 154 156 __FUNCTION__, this->process->pid, this->trdid, … … 168 170 thread_t * thread_ptr = GET_PTR( thread_xp ); 169 171 170 #if DEBUG_QUEUELOCK 171 if( DEBUG_QUEUELOCK < (uint32_t)hal_get_cycles())172 #if DEBUG_QUEUELOCK_TYPE 173 if( DEBUG_QUEUELOCK_TYPE == lock_type ) 172 174 { 173 175 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); -
trunk/kernel/libk/remote_rwlock.c
r603 r610 53 53 remote_busylock_init( XPTR( lock_cxy , &lock_ptr->lock ) , type ); 54 54 55 #if DEBUG_RWLOCK 55 #if DEBUG_RWLOCK_TYPE 56 56 thread_t * this = CURRENT_THREAD; 57 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())57 if( type == DEBUG_RWLOCK_TYPE ) 58 58 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 59 59 __FUNCTION__, this->process->pid, this->trdid, … … 75 75 cxy_t lock_cxy = GET_CXY( lock_xp ); 76 76 77 #if DEBUG_RWLOCK 77 #if DEBUG_RWLOCK_TYPE 78 78 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 79 79 #endif … … 92 92 { 93 93 94 #if DEBUG_RWLOCK 95 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())94 #if DEBUG_RWLOCK_TYPE 95 if( lock_type == DEBUG_RWLOCK_TYPE ) 96 96 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 97 97 __FUNCTION__, this->process->pid, this->trdid, … … 123 123 hal_fence(); 124 124 125 #if DEBUG_RWLOCK 126 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())125 #if DEBUG_RWLOCK_TYPE 126 if( lock_type == DEBUG_RWLOCK_TYPE ) 127 127 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken = %d / count = %d\n", 128 128 __FUNCTION__, this->process->pid, this->trdid, … … 148 148 cxy_t lock_cxy = GET_CXY( lock_xp ); 149 149 150 #if DEBUG_RWLOCK 150 #if DEBUG_RWLOCK_TYPE 151 151 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 152 152 #endif … … 165 165 { 166 166 167 #if DEBUG_RWLOCK 168 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())167 #if DEBUG_RWLOCK_TYPE 168 if( lock_type == DEBUG_RWLOCK_TYPE ) 169 169 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 170 170 __FUNCTION__, this->process->pid, this->trdid, … … 195 195 hal_remote_s32( taken_xp , 1 ); 196 196 197 #if DEBUG_RWLOCK 198 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())197 #if DEBUG_RWLOCK_TYPE 198 if( lock_type == DEBUG_RWLOCK_TYPE ) 199 199 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 200 200 __FUNCTION__, this->process->pid, this->trdid, … … 231 231 hal_remote_atomic_add( count_xp , -1 ); 232 232 233 #if DEBUG_RWLOCK 233 #if DEBUG_RWLOCK_TYPE 234 234 thread_t * this = CURRENT_THREAD; 235 235 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 236 236 xptr_t taken_xp = XPTR( lock_cxy , &lock_ptr->taken ); 237 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())237 if( lock_type == DEBUG_RWLOCK_TYPE ) 238 238 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 239 239 __FUNCTION__, this->process->pid, this->trdid, … … 257 257 thread_unblock( thread_xp , THREAD_BLOCKED_LOCK ); 258 258 259 #if DEBUG_RWLOCK 260 if( (uint32_t)hal_get_cycles() > DEBUG_RWLOCK)259 #if DEBUG_RWLOCK_TYPE 260 if( lock_type == DEBUG_RWLOCK_TYPE ) 261 261 { 262 262 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); … … 288 288 thread_unblock( thread_xp , THREAD_BLOCKED_LOCK ); 289 289 290 #if DEBUG_RWLOCK 291 if( (uint32_t)hal_get_cycles() > DEBUG_RWLOCK)290 #if DEBUG_RWLOCK_TYPE 291 if( lock_type == DEBUG_RWLOCK_TYPE ) 292 292 { 293 293 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); … … 330 330 hal_remote_s32( taken_xp , 0 ); 331 331 332 #if DEBUG_RWLOCK 332 #if DEBUG_RWLOCK_TYPE 333 333 thread_t * this = CURRENT_THREAD; 334 334 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 335 335 xptr_t count_xp = XPTR( lock_cxy , &lock_ptr->count ); 336 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())336 if( lock_type == DEBUG_RWLOCK_TYPE ) 337 337 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 338 338 __FUNCTION__, this->process->pid, this->trdid, … … 355 355 thread_unblock( thread_xp , THREAD_BLOCKED_LOCK ); 356 356 357 #if DEBUG_RWLOCK 358 if( (uint32_t)hal_get_cycles() > DEBUG_RWLOCK)357 #if DEBUG_RWLOCK_TYPE 358 if( lock_type == DEBUG_RWLOCK_TYPE ) 359 359 { 360 360 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); … … 385 385 thread_unblock( thread_xp , THREAD_BLOCKED_LOCK ); 386 386 387 #if DEBUG_RWLOCK 388 if( (uint32_t)hal_get_cycles() > DEBUG_RWLOCK)387 #if DEBUG_RWLOCK_TYPE 388 if( lock_type == DEBUG_RWLOCK_TYPE ) 389 389 { 390 390 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); -
trunk/kernel/libk/rwlock.c
r603 r610 50 50 busylock_init( &lock->lock , type ); 51 51 52 #if DEBUG_RWLOCK 52 #if DEBUG_RWLOCK_TYPE 53 53 thread_t * this = CURRENT_THREAD; 54 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())54 if( DEBUG_RWLOCK_TYPE == type ) 55 55 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 56 56 __FUNCTION__, this->process->pid, this->trdid, … … 75 75 { 76 76 77 #if DEBUG_RWLOCK 78 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 77 #if DEBUG_RWLOCK_TYPE 78 uint32_t lock_type = lock->lock.type; 79 if( DEBUG_RWLOCK_TYPE == lock_type ) 79 80 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 80 81 __FUNCTION__, this->process->pid, this->trdid, 81 lock_type_str[lock ->lock.type], local_cxy, lock, lock->taken, lock->count );82 lock_type_str[lock_type], local_cxy, lock, lock->taken, lock->count ); 82 83 #endif 83 84 // register reader thread in waiting queue … … 100 101 lock->count++; 101 102 102 #if DEBUG_RWLOCK 103 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())103 #if DEBUG_RWLOCK_TYPE 104 if( DEBUG_RWLOCK_TYPE == lock_type ) 104 105 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 105 106 __FUNCTION__, this->process->pid, this->trdid, 106 lock_type_str[lock ->lock.type], local_cxy, lock, lock->taken, lock->count );107 lock_type_str[lock_type], local_cxy, lock, lock->taken, lock->count ); 107 108 #endif 108 109 … … 127 128 { 128 129 129 #if DEBUG_RWLOCK 130 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 130 #if DEBUG_RWLOCK_TYPE 131 uint32_t lock_type = lock->lock.type; 132 if( DEBUG_RWLOCK_TYPE == lock_type ) 131 133 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 132 134 __FUNCTION__, this->process->pid, this->trdid, 133 lock_type_str[lock ->lock.type], local_cxy, lock, lock->taken, lock->count );135 lock_type_str[lock_type], local_cxy, lock, lock->taken, lock->count ); 134 136 #endif 135 137 // register writer in waiting queue … … 152 154 lock->taken = 1; 153 155 154 #if DEBUG_RWLOCK 155 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())156 #if DEBUG_RWLOCK_TYPE 157 if( DEBUG_RWLOCK_TYPE == lock_type ) 156 158 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 157 159 __FUNCTION__, this->process->pid, this->trdid, 158 lock_type_str[lock ->lock.type], local_cxy, lock, lock->taken, lock->count );160 lock_type_str[lock_type], local_cxy, lock, lock->taken, lock->count ); 159 161 #endif 160 162 … … 176 178 lock->count--; 177 179 178 #if DEBUG_RWLOCK 180 #if DEBUG_RWLOCK_TYPE 179 181 thread_t * this = CURRENT_THREAD; 180 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 182 uint32_t lock_type = lock->lock.type; 183 if( DEBUG_RWLOCK_TYPE == lock_type ) 181 184 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 182 185 __FUNCTION__, this->process->pid, this->trdid, 183 lock_type_str[lock ->lock.type], local_cxy, lock, lock->taken, lock->count );186 lock_type_str[lock_type], local_cxy, lock, lock->taken, lock->count ); 184 187 #endif 185 188 … … 191 194 thread_t * thread = LIST_FIRST( &lock->wr_root , thread_t , wait_list ); 192 195 193 #if DEBUG_RWLOCK 194 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())196 #if DEBUG_RWLOCK_TYPE 197 if( DEBUG_RWLOCK_TYPE == lock_type ) 195 198 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 196 199 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, 197 lock_type_str[lock ->lock.type], local_cxy, lock );200 lock_type_str[lock_type], local_cxy, lock ); 198 201 #endif 199 202 … … 213 216 thread_t * thread = LIST_FIRST( &lock->wr_root , thread_t , wait_list ); 214 217 215 #if DEBUG_RWLOCK 216 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())218 #if DEBUG_RWLOCK_TYPE 219 if( DEBUG_RWLOCK_TYPE == lock_type ) 217 220 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 218 221 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, 219 lock_type_str[lock ->lock.type], local_cxy, lock );222 lock_type_str[lock_type], local_cxy, lock ); 220 223 #endif 221 224 … … 245 248 lock->taken = 0; 246 249 247 #if DEBUG_RWLOCK 250 #if DEBUG_RWLOCK_TYPE 248 251 thread_t * this = CURRENT_THREAD; 249 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 252 uint32_t lock_type = lock->lock.type; 253 if( DEBUG_RWLOCK_TYPE == lock_type ) 250 254 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 251 255 __FUNCTION__, this->process->pid, this->trdid, 252 lock_type_str[lock ->lock.type], local_cxy, lock, lock->taken, lock->count );256 lock_type_str[lock_type], local_cxy, lock, lock->taken, lock->count ); 253 257 #endif 254 258 … … 259 263 thread_t * thread = LIST_FIRST( &lock->wr_root , thread_t , wait_list ); 260 264 261 #if DEBUG_RWLOCK 262 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())265 #if DEBUG_RWLOCK_TYPE 266 if( DEBUG_RWLOCK_TYPE == lock_type ) 263 267 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 264 268 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, 265 lock_type_str[lock ->lock.type], local_cxy, lock );269 lock_type_str[lock_type], local_cxy, lock ); 266 270 #endif 267 271 // remove this waiting thread from waiting list … … 280 284 thread_t * thread = LIST_FIRST( &lock->rd_root , thread_t , wait_list ); 281 285 282 #if DEBUG_RWLOCK 283 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles())286 #if DEBUG_RWLOCK_TYPE 287 if( DEBUG_RWLOCK_TYPE == lock_type ) 284 288 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 285 289 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, 286 lock_type_str[lock ->lock.type], local_cxy, lock );290 lock_type_str[lock_type], local_cxy, lock ); 287 291 #endif 288 292 // remove this waiting thread from waiting list -
trunk/kernel/libk/xhtab.c
r603 r610 40 40 41 41 /////////////////////////////////////////////////////////////////////////////////////////// 42 // vfs_dentry_t42 // XHTAB_DENTRY_TYPE 43 43 // This functions compute the hash index from the key, that is the directory entry name. 44 44 /////////////////////////////////////////////////////////////////////////////////////////// … … 58 58 59 59 /////////////////////////////////////////////////////////////////////////////////////////// 60 // vfs_dentry_t60 // XHTAB_DENTRY_TYPE 61 61 // This functions returns the extended pointer on the item, from the extended pointer 62 62 // on xlist contained in the item. … … 67 67 static xptr_t xhtab_dentry_item_from_xlist( xptr_t xlist_xp ) 68 68 { 69 return XLIST_ELEMENT( xlist_xp , vfs_dentry_t , list);69 return XLIST_ELEMENT( xlist_xp , vfs_dentry_t , children ); 70 70 } 71 71 72 72 //////////////////////////////////////////////////////////////////////////////////////////// 73 // vfs_dentry_t73 // XHTAB_DENTRY_TYPE 74 74 // This function compares the identifier of an item to a given <key>. 75 75 // it returns true when the directory name matches the name pointed by the <key> argument. … … 96 96 97 97 //////////////////////////////////////////////////////////////////////////////////////////// 98 // vfs_dentry_t98 // XHTAB_DENTRY_TYPE 99 99 // This function print the item key, that is the name for a vfs_dentry_t. 100 100 //////////////////////////////////////////////////////////////////////////////////////////// … … 150 150 xlist_root_init( XPTR( local_cxy , &xhtab->roots[i] ) ); 151 151 } 152 153 #if DEBUG_XHTAB 154 printk("\n@@@ %s for xhtab (%x,%x)\n" 155 " - index_from_key = %x (@ %x)\n" 156 " - item_match_key = %x (@ %x)\n" 157 " - item_from_xlist = %x (@ %x)\n", 158 __FUNCTION__, local_cxy, xhtab, 159 xhtab->index_from_key , &xhtab->index_from_key, 160 xhtab->item_match_key , &xhtab->item_match_key, 161 xhtab->item_from_xlist, &xhtab->item_from_xlist ); 162 #endif 152 163 153 164 } // end xhtab_init() -
trunk/kernel/libk/xhtab.h
r603 r610 73 73 /****************************************************************************************** 74 74 * This define the supported item types. 75 * - The XHTAB_DENTRY_TYPE is used to implement the set of directory entries for a 76 * directory inode : the "children" inode field is an embedded xhtab. 75 77 *****************************************************************************************/ 76 78 -
trunk/kernel/libk/xlist.h
r603 r610 5 5 * xlist.h - Double Circular Linked lists, using extended pointers. 6 6 * 7 * Author : Alain Greiner (2016 )7 * Author : Alain Greiner (2016,2017,2018) 8 8 * 9 9 * Copyright (c) UPMC Sorbonne Universites … … 31 31 #include <hal_kernel_types.h> 32 32 #include <hal_remote.h> 33 #include <printk.h> 33 34 34 35 /**** global variables ***/ … … 190 191 * double linked list. Four extended pointers must be modified. 191 192 * The lock protecting the list should have been previously taken. 192 * @ root : extended pointer on the root xlist_entry_t193 * @ entry : extended pointer on the xlist_entry_t to be inserted194 **************************************************************************/ 195 static inline void xlist_add_first( xptr_t root ,196 xptr_t entry )193 * @ root_xp : extended pointer on the root xlist_entry_t 194 * @ entry_xp : extended pointer on the xlist_entry_t to be inserted 195 **************************************************************************/ 196 static inline void xlist_add_first( xptr_t root_xp, 197 xptr_t entry_xp ) 197 198 { 198 199 // get the extended pointer on the first element in list 199 xptr_t first = (xptr_t)hal_remote_l64( root);200 201 // update root .next <= entry202 hal_remote_s64( root , (uint64_t)entry);203 204 // update entry .next <= first205 hal_remote_s64( entry , (uint64_t)first);206 207 // entry.pred <= root208 hal_remote_s64( entry + sizeof(xptr_t) , (uint64_t)root);200 xptr_t first_xp = hal_remote_l64( root_xp ); 201 202 // update root_xp->next <= entry_xp 203 hal_remote_s64( root_xp , entry_xp ); 204 205 // update entry_xp->next <= first_xp 206 hal_remote_s64( entry_xp , first_xp ); 207 208 // update entry_xp->pred <= root_xp 209 hal_remote_s64( entry_xp + sizeof(xptr_t) , root_xp ); 209 210 210 // first.pred <= new211 hal_remote_s64( first + sizeof(xptr_t) , (uint64_t)entry);211 // update first_xp->pred <= entry_xp 212 hal_remote_s64( first_xp + sizeof(xptr_t) , entry_xp ); 212 213 } 213 214 … … 216 217 * double linked list. Four extended pointers must be modified. 217 218 * The lock protecting the list should have been previously taken. 218 * @ root : extended pointer on the root xlist_entry_t219 * @ entry : extended pointer on the xlist_entry_t to be inserted220 **************************************************************************/ 221 static inline void xlist_add_last( xptr_t root ,222 xptr_t entry )219 * @ root_xp : extended pointer on the root xlist_entry_t 220 * @ entry_xp : extended pointer on the xlist_entry_t to be inserted 221 **************************************************************************/ 222 static inline void xlist_add_last( xptr_t root_xp, 223 xptr_t entry_xp ) 223 224 { 224 225 // get the extended pointer on the last element in list 225 xptr_t last = (xptr_t)hal_remote_l64( root+ sizeof(xptr_t) );226 227 // update root .pred <= entry228 hal_remote_s64( root + sizeof(xptr_t) , (uint64_t)entry);229 230 // update entry .pred <= last231 hal_remote_s64( entry + sizeof(xptr_t) , (uint64_t)last);232 233 // entry.next <= root234 hal_remote_s64( entry , (uint64_t)root);226 xptr_t last_xp = hal_remote_l64( root_xp + sizeof(xptr_t) ); 227 228 // update root_xp->pred <= entry_xp 229 hal_remote_s64( root_xp + sizeof(xptr_t) , entry_xp ); 230 231 // update entry_xp->pred <= last_xp 232 hal_remote_s64( entry_xp + sizeof(xptr_t) , last_xp ); 233 234 // update entry_xp->next <= root_xp 235 hal_remote_s64( entry_xp , root_xp ); 235 236 236 // last.next <= entry237 hal_remote_s64( last , (uint64_t)entry);237 // update last_xp->next <= entry_xp 238 hal_remote_s64( last_xp , entry_xp ); 238 239 } 239 240 … … 241 242 /*************************************************************************** 242 243 * This function returns true if the list is empty. 243 * @ root : extended pointer on the root xlist_entry_t244 **************************************************************************/ 245 static inline bool_t xlist_is_empty( xptr_t root )244 * @ root_xp : extended pointer on the root xlist_entry_t. 245 **************************************************************************/ 246 static inline bool_t xlist_is_empty( xptr_t root_xp ) 246 247 { 247 248 // get the extended pointer root.next value 248 xptr_t next = (xptr_t)hal_remote_l64( root );249 250 return ( root == next );249 xptr_t next = (xptr_t)hal_remote_l64( root_xp ); 250 251 return ( root_xp == next ); 251 252 } 252 253 … … 279 280 * Four extended pointers must be modified. 280 281 * The memory allocated to the removed entry is not released. 281 * @ old : extended pointer on the xlist_entry_t to be removed.282 * @ new : extended pointer on the xlist_entry_t to be inserted.282 * @ old : extended pointer on the xlist_entry_t to be removed. 283 * @ new : extended pointer on the xlist_entry_t to be inserted. 283 284 **************************************************************************/ 284 285 static inline void xlist_replace( xptr_t old, … … 307 308 } 308 309 310 /*************************************************************************** 311 * This debug function displays all entries of an xlist. 312 * @ root_xp : extended pointer on the root xlist_entry_t. 313 * @ string : list identifier displayed in header. 314 * @ max : max number of éléments to display. 315 **************************************************************************/ 316 static inline void xlist_display( xptr_t root_xp, 317 char * string, 318 uint32_t max ) 319 { 320 cxy_t root_cxy; 321 xlist_entry_t * root_ptr; 322 323 xptr_t iter_xp; 324 cxy_t iter_cxy; 325 xlist_entry_t * iter_ptr; 326 327 xptr_t next_xp; 328 cxy_t next_cxy; 329 xlist_entry_t * next_ptr; 330 331 xptr_t pred_xp; 332 cxy_t pred_cxy; 333 xlist_entry_t * pred_ptr; 334 335 uint32_t index; 336 337 root_cxy = GET_CXY( root_xp ); 338 root_ptr = GET_PTR( root_xp ); 339 340 next_xp = hal_remote_l64( XPTR( root_cxy , &root_ptr->next ) ); 341 next_cxy = GET_CXY( next_xp ); 342 next_ptr = GET_PTR( next_xp ); 343 344 pred_xp = hal_remote_l64( XPTR( root_cxy , &root_ptr->pred ) ); 345 pred_cxy = GET_CXY( pred_xp ); 346 pred_ptr = GET_PTR( pred_xp ); 347 348 printk("\n***** root (%x,%x) / next (%x,%x) / pred (%x,%x) / %s *****\n", 349 root_cxy, root_ptr, next_cxy, next_ptr, pred_cxy, pred_ptr, string ); 350 351 if( xlist_is_empty( root_xp ) == false ) 352 { 353 for( iter_xp = hal_remote_l64( XPTR( root_cxy , &root_ptr->next) ) , index = 0 ; 354 (iter_xp != root_xp) && (index < max) ; 355 iter_xp = next_xp , index++ ) 356 { 357 iter_cxy = GET_CXY( iter_xp ); 358 iter_ptr = GET_PTR( iter_xp ); 359 360 next_xp = hal_remote_l64( XPTR( iter_cxy , &iter_ptr->next ) ); 361 next_cxy = GET_CXY( next_xp ); 362 next_ptr = GET_PTR( next_xp ); 363 364 pred_xp = hal_remote_l64( XPTR( iter_cxy , &iter_ptr->pred ) ); 365 pred_cxy = GET_CXY( pred_xp ); 366 pred_ptr = GET_PTR( pred_xp ); 367 368 printk(" - %d : iter (%x,%x) / next (%x,%x) / pred (%x,%x)\n", 369 index, iter_cxy, iter_ptr, next_cxy, next_ptr, pred_cxy, pred_ptr ); 370 } 371 } 372 } // end xlist_display() 373 309 374 #endif /* _XLIST_H_ */
Note: See TracChangeset
for help on using the changeset viewer.