函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\locking\semaphore.c Create Date:2022-07-27 10:48:09
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Because this function is inlined, the 'state' parameter will be* constant, and thus optimised away by the compiler. Likewise the* 'timeout' parameter for the cases without timeouts.

函数原型:static inline int __sched __down_common(struct semaphore *sem, long state, long timeout)

返回类型:int

参数:

类型参数名称
struct semaphore *sem
longstate
longtimeout
209  添加链表项
210  task等于当前进程
211  up = false
213  循环
214  如果signal_pending_state(state, 当前进程)则转到:interrupted
216  如果此条件成立可能性小(为编译器优化)(timeout <= 0)则转到:timed_out
218  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (state)
219  raw_spin_unlock_irq( & lock)
220  timeout等于schedule_timeout - sleep until timeout*@timeout: timeout value in jiffies* Make the current task sleep until @timeout jiffies have* elapsed
221  关闭本地中断,获取所要保护的运行队列(runqueue)的自旋锁(spinlock),为查找可运行进程做准备。( & lock)
222  如果up则返回:0
226  timed_out :
227  删除链表项
228  返回:负ETIME
230  interrupted :
231  删除链表项
232  返回:负EINTR
调用者
名称描述
__down
__down_interruptible
__down_killable
__down_timeout