Changeset 409 for trunk/kernel/libk/remote_rwlock.c
- Timestamp:
- Dec 20, 2017, 4:51:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_rwlock.c
r337 r409 40 40 hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->current ) , 0 ); 41 41 hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->count ) , 0 ); 42 43 #if CONFIG_LOCKS_DEBUG 42 44 hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL ); 45 xlist_entry_init( XPTR( lock_cxy , &lock_ptr->list ) ); 46 #endif 47 43 48 } 44 49 … … 53 58 cxy_t lock_cxy = GET_CXY( lock_xp ); 54 59 55 // get cluster andlocal pointer on local thread60 // get local pointer on local thread 56 61 thread_t * thread_ptr = CURRENT_THREAD; 57 62 … … 81 86 thread_ptr->remote_locks++; 82 87 88 #if CONFIG_LOCKS_DEBUG 89 xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) , 90 XPTR( lock_cxy , &lock_ptr->list ) ); 91 #endif 92 83 93 // sync 84 94 hal_fence(); … … 115 125 // decrement thread.remote_locks 116 126 thread_ptr->remote_locks--; 127 128 #if CONFIG_LOCKS_DEBUG 129 xlist_unlink( XPTR( lock_cxy , &lock->ptr->list ) ); 130 #endif 117 131 118 132 // enable interrupts … … 134 148 cxy_t lock_cxy = GET_CXY( lock_xp ); 135 149 136 // get cluster and local pointer on local thread 137 cxy_t thread_cxy = local_cxy; 150 // get local pointer on local thread 138 151 thread_t * thread_ptr = CURRENT_THREAD; 139 152 … … 142 155 xptr_t count_xp = XPTR( lock_cxy , &lock_ptr->count ); 143 156 xptr_t current_xp = XPTR( lock_cxy , &lock_ptr->current ); 144 xptr_t owner_xp = XPTR( lock_cxy , &lock_ptr->owner );145 xptr_t thread_xp = XPTR( thread_cxy , thread_ptr );146 157 147 158 // disable interrupts … … 165 176 } 166 177 167 // register owner thread 168 hal_remote_swd( owner_xp , thread_xp ); 178 #if CONFIG_LOCKS_DEBUG 179 hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , 180 XPTR( local_cxy , thread_ptr ) ); 181 xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) , 182 XPTR( lock_cxy , &lock_ptr->list ) ); 183 #endif 169 184 170 185 // increment thread.remote_locks … … 188 203 thread_t * thread_ptr = CURRENT_THREAD; 189 204 190 // compute extended pointer s on lock->ticket, lock->owner205 // compute extended pointer on lock->ticket 191 206 xptr_t current_xp = XPTR( lock_cxy , &lock_ptr->current ); 192 xptr_t owner_xp = XPTR( lock_cxy , &lock_ptr->owner );193 207 194 208 // disable interrupts 195 209 hal_disable_irq( &mode ); 196 210 197 // unregister owner thread, and release lock 198 hal_remote_swd( owner_xp , XPTR_NULL ); 211 #if CONFIG_LOCKS_OWNER 212 hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL ); 213 xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) ); 214 #endif 215 216 // release lock 199 217 hal_remote_atomic_add( current_xp , 1 ); 200 218 … … 217 235 uint32_t current; // ticket index of current owner 218 236 uint32_t count; // current number of reader threads 219 xptr_t owner; // extended pointer on writer thread220 237 221 238 // get cluster and local pointer on remote_rwlock … … 226 243 current = hal_remote_lw ( XPTR( lock_cxy , &lock_ptr->current ) ); 227 244 count = hal_remote_lw ( XPTR( lock_cxy , &lock_ptr->count ) ); 228 owner = hal_remote_lwd( XPTR( lock_cxy , &lock_ptr->owner ) ); 229 230 printk("\n*** rwlock <%l> %s : ticket = %d / current = %d / count = %d / owner = %l\n", 231 lock_xp , comment , ticket , current , count , owner ); 245 246 printk("\n*** rwlock <%l> %s : ticket = %d / current = %d / count = %d\n", 247 lock_xp , comment , ticket , current , count ); 232 248 233 249 } // end remote_rwlock_print()
Note: See TracChangeset
for help on using the changeset viewer.