Changeset 603 for trunk/kernel/libk/rwlock.c
- Timestamp:
- Dec 3, 2018, 12:17:35 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/rwlock.c
r600 r603 49 49 50 50 busylock_init( &lock->lock , type ); 51 52 #if DEBUG_RWLOCK 53 thread_t * this = CURRENT_THREAD; 54 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 55 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 56 __FUNCTION__, this->process->pid, this->trdid, 57 lock_type_str[type], local_cxy, lock ); 58 #endif 59 51 60 } 52 61 … … 68 77 #if DEBUG_RWLOCK 69 78 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 70 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] \n",71 __FUNCTION__, this->process->pid, this->trdid, 72 lock_type_str[lock->lock.type], local_cxy, lock );79 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 80 __FUNCTION__, this->process->pid, this->trdid, 81 lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count ); 73 82 #endif 74 83 // register reader thread in waiting queue … … 88 97 } 89 98 90 #if DEBUG_RWLOCK91 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )92 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x]\n",93 __FUNCTION__, this->process->pid, this->trdid,94 lock_type_str[lock->lock.type], local_cxy, lock );95 #endif96 97 99 // increment number of readers 98 100 lock->count++; 101 102 #if DEBUG_RWLOCK 103 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 104 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 105 __FUNCTION__, this->process->pid, this->trdid, 106 lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count ); 107 #endif 99 108 100 109 // release busylock … … 120 129 #if DEBUG_RWLOCK 121 130 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 122 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] \n",123 __FUNCTION__, this->process->pid, this->trdid, 124 lock_type_str[lock->lock.type], local_cxy, lock );131 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 132 __FUNCTION__, this->process->pid, this->trdid, 133 lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count ); 125 134 #endif 126 135 // register writer in waiting queue 127 136 list_add_last( &lock->wr_root , &this->wait_list ); 128 137 129 // block reader thread138 // block writer thread 130 139 thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_LOCK ); 131 140 … … 140 149 } 141 150 142 #if DEBUG_RWLOCK143 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )144 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x]\n",145 __FUNCTION__, this->process->pid, this->trdid,146 lock_type_str[lock->lock.type], local_cxy, lock );147 #endif148 149 151 // take the rwlock 150 152 lock->taken = 1; 153 154 #if DEBUG_RWLOCK 155 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 156 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 157 __FUNCTION__, this->process->pid, this->trdid, 158 lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count ); 159 #endif 151 160 152 161 // release busylock … … 164 173 busylock_acquire( &lock->lock ); 165 174 166 #if DEBUG_RWLOCK167 thread_t * this = CURRENT_THREAD;168 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )169 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x]\n",170 __FUNCTION__, this->process->pid, this->trdid,171 lock_type_str[lock->lock.type], local_cxy, lock );172 #endif173 174 175 // decrement number of readers 175 176 lock->count--; 177 178 #if DEBUG_RWLOCK 179 thread_t * this = CURRENT_THREAD; 180 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 181 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 182 __FUNCTION__, this->process->pid, this->trdid, 183 lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count ); 184 #endif 176 185 177 186 // release first writer in waiting queue if no current readers … … 233 242 busylock_acquire( &lock->lock ); 234 243 235 #if DEBUG_RWLOCK236 thread_t * this = CURRENT_THREAD;237 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() )238 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x]\n",239 __FUNCTION__, this->process->pid, this->trdid,240 lock_type_str[lock->lock.type], local_cxy, lock );241 #endif242 243 244 // release the rwlock 244 245 lock->taken = 0; 246 247 #if DEBUG_RWLOCK 248 thread_t * this = CURRENT_THREAD; 249 if( DEBUG_RWLOCK < (uint32_t)hal_get_cycles() ) 250 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 251 __FUNCTION__, this->process->pid, this->trdid, 252 lock_type_str[lock->lock.type], local_cxy, lock, lock->taken, lock->count ); 253 #endif 245 254 246 255 // release first waiting writer thread if writers waiting queue non empty
Note: See TracChangeset
for help on using the changeset viewer.