Changeset 603 for trunk/kernel/libk/remote_rwlock.c
- Timestamp:
- Dec 3, 2018, 12:17:35 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_rwlock.c
r600 r603 52 52 53 53 remote_busylock_init( XPTR( lock_cxy , &lock_ptr->lock ) , type ); 54 55 #if DEBUG_RWLOCK 56 thread_t * this = CURRENT_THREAD; 57 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 58 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 59 __FUNCTION__, this->process->pid, this->trdid, 60 lock_type_str[type], local_cxy, lock_ptr ); 61 #endif 62 54 63 } 55 64 … … 85 94 #if DEBUG_RWLOCK 86 95 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 87 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] \n",96 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 88 97 __FUNCTION__, this->process->pid, this->trdid, 89 lock_type_str[lock_type], lock_cxy, lock_ptr ); 98 lock_type_str[lock_type], lock_cxy, lock_ptr, 99 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 90 100 #endif 91 101 // get pointer on calling thread … … 108 118 } 109 119 110 #if DEBUG_RWLOCK111 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )112 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x]\n",113 __FUNCTION__, this->process->pid, this->trdid,114 lock_type_str[lock_type], lock_cxy, lock_ptr );115 #endif116 117 120 // increment number of readers 118 121 hal_remote_atomic_add( count_xp , 1 ); 122 123 hal_fence(); 124 125 #if DEBUG_RWLOCK 126 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 127 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken = %d / count = %d\n", 128 __FUNCTION__, this->process->pid, this->trdid, 129 lock_type_str[lock_type], lock_cxy, lock_ptr, 130 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 131 #endif 119 132 120 133 // release busylock … … 154 167 #if DEBUG_RWLOCK 155 168 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 156 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] \n",169 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 157 170 __FUNCTION__, this->process->pid, this->trdid, 158 lock_type_str[lock_type], lock_cxy, lock_ptr ); 159 #endif 171 lock_type_str[lock_type], lock_cxy, lock_ptr, 172 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 173 #endif 174 160 175 // get local pointer on calling thread 161 176 thread_t * this = CURRENT_THREAD; … … 177 192 } 178 193 179 #if DEBUG_RWLOCK 180 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 181 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x]\n", 194 // take rwlock for write 195 hal_remote_s32( taken_xp , 1 ); 196 197 #if DEBUG_RWLOCK 198 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 199 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 182 200 __FUNCTION__, this->process->pid, this->trdid, 183 lock_type_str[lock_type], lock_cxy, lock_ptr ); 184 #endif 185 186 // take rwlock 187 hal_remote_s32( taken_xp , 1 ); 201 lock_type_str[lock_type], lock_cxy, lock_ptr, 202 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 203 #endif 188 204 189 205 // release busylock … … 212 228 remote_busylock_acquire( busylock_xp ); 213 229 230 // decrement number of readers 231 hal_remote_atomic_add( count_xp , -1 ); 232 214 233 #if DEBUG_RWLOCK 215 234 thread_t * this = CURRENT_THREAD; 216 235 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 217 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 218 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x]\n", 236 xptr_t taken_xp = XPTR( lock_cxy , &lock_ptr->taken ); 237 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 238 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 219 239 __FUNCTION__, this->process->pid, this->trdid, 220 lock_type_str[lock_type], lock_cxy, lock_ptr ); 221 #endif 222 223 // decrement number of readers 224 hal_remote_atomic_add( count_xp , -1 ); 240 lock_type_str[lock_type], lock_cxy, lock_ptr, 241 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 242 #endif 225 243 226 244 // release first writer in waiting queue if no current readers … … 309 327 remote_busylock_acquire( busylock_xp ); 310 328 329 // release rwlock 330 hal_remote_s32( taken_xp , 0 ); 331 311 332 #if DEBUG_RWLOCK 312 333 thread_t * this = CURRENT_THREAD; 313 334 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 314 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 315 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x]\n", 335 xptr_t count_xp = XPTR( lock_cxy , &lock_ptr->count ); 336 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 337 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 316 338 __FUNCTION__, this->process->pid, this->trdid, 317 lock_type_str[lock_type], lock_cxy, lock_ptr ); 318 #endif 319 320 // release rwlock 321 hal_remote_s32( taken_xp , 0 ); 339 lock_type_str[lock_type], lock_cxy, lock_ptr, 340 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 341 #endif 322 342 323 343 // unblock first waiting writer thread if writers waiting queue non empty
Note: See TracChangeset
for help on using the changeset viewer.