Пример #1
0
/**
 * down_interruptible - acquire the semaphore unless interrupted
 * @sem: the semaphore to be acquired
 *
 * Attempts to acquire the semaphore.  If no more tasks are allowed to
 * acquire the semaphore, calling this function will put the task to sleep.
 * If the sleep is interrupted by a signal, this function will return -EINTR.
 * If the semaphore is successfully acquired, this function returns 0.
 */
int down_interruptible(struct semaphore *sem)
{
	unsigned long flags;
	int result = 0;

	spin_lock_irqsave(&sem->lock, flags);
	if (likely(sem->count > 0)){
		sem->count--;
	}else{
#ifdef CONFIG_MT_LOCK_DEBUG
        if(sem->owner == current){
	        char aee_str[40];
            printk("[Warning!Recursive Semaphore!][%d:%s], down_interruptible:%s(0x%x)\n", current->pid, current->comm, sem->sem_name, sem);
            sprintf( aee_str, "Recursive SemLock:%s\n", current->comm);
            aee_kernel_warning( aee_str,"mtlock debugger\n");
            dump_stack();
        }
#endif
		result = __down_interruptible(sem);
    }
#ifdef CONFIG_MT_LOCK_DEBUG
    if(0 == sem->count)
        sem_set_owner(sem);
#endif
	spin_unlock_irqrestore(&sem->lock, flags);

	return result;
}
Пример #2
0
int __sched
down_interruptible(struct semaphore *sem)
{
#ifdef WAITQUEUE_DEBUG
	CHECK_MAGIC(sem->__magic);
#endif
#ifdef CONFIG_DEBUG_SEMAPHORE
	printk("%s(%d): down(%p) <count=%d> from %p\n",
	       current->comm, current->pid, sem,
	       atomic_read(&sem->count), __builtin_return_address(0));
#endif
	return __down_interruptible(sem);
}
Пример #3
0
int down_interruptible(struct semaphore *sem)
{
	unsigned long flags;
	int result = 0;

	spin_lock_irqsave(&sem->lock, flags);
	if (likely(sem->count > 0))
		sem->count--;
	else
		result = __down_interruptible(sem);
	spin_unlock_irqrestore(&sem->lock, flags);

	return result;
}
Пример #4
0
/**
 * down_interruptible - acquire the semaphore unless interrupted
 * @sem: the semaphore to be acquired
 *
 * Attempts to acquire the semaphore.  If no more tasks are allowed to
 * acquire the semaphore, calling this function will put the task to sleep.
 * If the sleep is interrupted by a signal, this function will return -EINTR.
 * If the semaphore is successfully acquired, this function returns 0.
 */
int down_interruptible(struct semaphore *sem)
{
	unsigned long flags;
	int result = 0;

	raw_spin_lock_irqsave(&sem->lock, flags);
#ifdef CONFIG_ILOCKDEP
	ilockdep_acquire(&sem->idep_map, _RET_IP_, (void *)sem);
#endif
	if (likely(sem->count > 0))
		sem->count--;
	else
		result = __down_interruptible(sem);
#ifdef CONFIG_ILOCKDEP
	if (result)
		ilockdep_clear_locking(current);
	else
		ilockdep_acquired(&sem->idep_map, _RET_IP_, (void *)sem);
#endif
	raw_spin_unlock_irqrestore(&sem->lock, flags);

	return result;
}