函数逻辑报告 |
Source Code:kernel\locking\rwsem.c |
Create Date:2022-07-27 10:48:43 |
Last Modify:2020-03-12 14:18:49 | Copyright©Brick |
首页 | 函数Tree |
注解内核,赢得工具 | 下载SCCT | English |
函数名称:Wait until we successfully acquire the write lock
函数原型:static struct rw_semaphore *rwsem_down_write_slowpath(struct rw_semaphore *sem, int state)
返回类型:struct rw_semaphore
参数:
类型 | 参数 | 名称 |
---|---|---|
struct rw_semaphore * | sem | |
int | state |
1149 | 如果rwsem_can_spin_on_owner(sem, RWSEM_WR_NONSPINNABLE)且rwsem_optimistic_spin(sem, true)则 |
1152 | 返回:sem |
1167 | type等于RWSEM_WAITING_FOR_WRITE |
1175 | 添加链表项 |
1178 | 如果wstate恒等于 Writer is not first in wait list 则 |
1179 | count等于atomic_long_read( & count) |
1189 | 如果count按位与RWSEM_WRITER_MASK则转到:wait |
1196 | 如果非wake_q_empty( & wake_q)则 |
1201 | raw_spin_unlock_irq( & wait_lock) |
1203 | wake_q_init( & wake_q) |
1206 | 否则 |
1207 | atomic_long_or(RWSEM_FLAG_WAITERS, & count) |
1210 | wait : |
1212 | set_current_state(state) |
1213 | 循环 |
1216 | 退出 |
1219 | raw_spin_unlock_irq( & wait_lock) |
1229 | 如果wstate恒等于WRITER_HANDOFF且rwsem_spin_on_owner(sem, RWSEM_NONSPINNABLE)恒等于OWNER_NULL则转到:trylock_again |
1234 | 循环 |
1235 | 如果signal_pending_state(state, 当前进程)则转到:out_nolock |
1238 | 进程调度 |
1240 | set_current_state(state) |
1245 | 如果wstate恒等于WRITER_HANDOFF则退出 |
1248 | 如果wstate恒等于 Writer is not first in wait list 且rwsem_first_waiter(sem)恒等于waiter则wstate等于 Writer is first in wait list |
1252 | count等于atomic_long_read( & count) |
1253 | 如果非count按位与RWSEM_LOCK_MASK的值则退出 |
1262 | wstate等于WRITER_HANDOFF |
1264 | 退出 |
1267 | trylock_again : |
1271 | 删除链表项 |
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 | 返回:ret |
1278 | out_nolock : |
1281 | 删除链表项 |
1283 | 如果此条件成立可能性小(为编译器优化)(wstate == WRITER_HANDOFF)则atomic_long_add( - RWSEM_FLAG_HANDOFF, & count) |
1286 | 如果链表为空则atomic_long_andnot(RWSEM_FLAG_WAITERS, & count) |
1290 | raw_spin_unlock_irq( & wait_lock) |
1294 | 返回:错误号 |
名称 | 描述 |
---|---|
__down_write | lock for writing |
__down_write_killable |
源代码转换工具 开放的插件接口 | X |
---|---|
支持:c/c++/esqlc/java Oracle/Informix/Mysql 插件可实现:逻辑报告 代码生成和批量转换代码 |