| Function report | 
| Source Code: kernel\locking\rwsem.c | Create Date:2022-07-28 09:48:21 | 
| Last Modify:2020-03-12 14:18:49 | Copyright©Brick | 
| home page | Tree | 
| Annotation kernel can get tool activity | Download SCCT | Chinese | 
Name:Wait until we successfully acquire the write lock
Proto:static struct rw_semaphore *rwsem_down_write_slowpath(struct rw_semaphore *sem, int state)
Type:struct rw_semaphore
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| struct rw_semaphore * | sem | |
| int | state | 
| 1149 | If rwsem_can_spin_on_owner(sem, RWSEM_WR_NONSPINNABLE) && rwsem_optimistic_spin(sem, true) Then | 
| 1152 | Return sem | 
| 1166 | task = current process | 
| 1167 | type = RWSEM_WAITING_FOR_WRITE | 
| 1170 | raw_spin_lock_irq( & wait_lock) | 
| 1173 | wstate = If list_empty - tests whether a list is empty*@head: the list to test. Then Writer is first in wait list Else Writer is not first in wait list | 
| 1178 | If wstate == Writer is not first in wait list Then | 
| 1179 | count = atomic_long_read( & count) | 
| 1189 | If count & RWSEM_WRITER_MASK Then Go to wait | 
| 1196 | If Not wake_q_empty( & wake_q) Then | 
| 1201 | raw_spin_unlock_irq( & wait_lock) | 
| 1203 | wake_q_init( & wake_q) | 
| 1204 | raw_spin_lock_irq( & wait_lock) | 
| 1206 | Else | 
| 1207 | atomic_long_or(RWSEM_FLAG_WAITERS, & count) | 
| 1210 | wait : | 
| 1212 | set_current_state(state) | 
| 1213 | cycle | 
| 1216 | Break | 
| 1219 | raw_spin_unlock_irq( & wait_lock) | 
| 1229 | If wstate == WRITER_HANDOFF && rwsem_spin_on_owner(sem, RWSEM_NONSPINNABLE) == OWNER_NULL Then Go to trylock_again | 
| 1234 | cycle | 
| 1235 | If signal_pending_state(state, current process) Then Go to out_nolock | 
| 1238 | schedule() | 
| 1240 | set_current_state(state) | 
| 1245 | If wstate == WRITER_HANDOFF Then Break | 
| 1248 | If wstate == Writer is not first in wait list && rwsem_first_waiter(sem) == waiter Then wstate = Writer is first in wait list | 
| 1252 | count = atomic_long_read( & count) | 
| 1253 | If Not (count & RWSEM_LOCK_MASK) Then Break | 
| 1262 | wstate = WRITER_HANDOFF | 
| 1264 | Break | 
| 1267 | trylock_again : | 
| 1268 | raw_spin_lock_irq( & wait_lock) | 
| 1272 | This function is called by the a write lock owner. So the owner value* won't get changed by others. | 
| 1273 | raw_spin_unlock_irq( & wait_lock) | 
| 1276 | Return ret | 
| 1278 | out_nolock : | 
| 1280 | raw_spin_lock_irq( & wait_lock) | 
| 1283 | If Value for the false possibility is greater at compile time(wstate == WRITER_HANDOFF) Then atomic_long_add( - RWSEM_FLAG_HANDOFF, & count) | 
| 1286 | If list_empty - tests whether a list is empty*@head: the list to test. Then atomic_long_andnot(RWSEM_FLAG_WAITERS, & count) | 
| 1290 | raw_spin_unlock_irq( & wait_lock) | 
| Name | Describe | 
|---|---|
| __down_write | lock for writing | 
| __down_write_killable | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |