int down_interruptible(struct semaphore *sem) 如果得不到信号量,此时没有信号打断,那么进入睡眠。 主要用来进程间的互斥同步 你如果看函数的注释,也可以知道大概的 66/** 67 * down_interruptible - acquire the semaphore unless interrupted 68 * @sem: the semaphore to be acquired 69 * 70 * Attempts to acquire the semaphore. If no more tasks are allowed to 71 * acquire the semaphore, calling this function will put the task to sleep. 72 * If the sleep is interrupted by a signal, this function will return -EINTR. 73 * If the semaphore is successfully acquired, this function returns 0. 74 */ 75int down_interruptible(struct semaphore *sem) 传入的信号量为1好比天亮,如果当前信号量为0,进程睡眠,直到(信号量为1)天亮才醒,但是可能中途有个闹铃(信号)把你闹醒。 |
|