Ways To Wait in the Kernel


See this link:  http://www.lisoleg.net/doc/Kernel-Hacking-HOWTO/kernel-hacking-HOWTO-5.html

Look at this code

static void __wait_on_inode(struct inode * inode)
{
        DECLARE_WAITQUEUE(wait, current);

        add_wait_queue(&inode->i_wait, &wait);
repeat:
        set_current_state(TASK_UNINTERRUPTIBLE);
        if (inode->i_state & I_LOCK) {
                schedule();
                goto repeat;
        }
        remove_wait_queue(&inode->i_wait, &wait);
        current->state = TASK_RUNNING;
}


Also, look for mount_sem in /usr/src/linux/fs/super.c.  It gets declared and used all there.