本文整理汇总了C++中LOCK_CONTENDED函数的典型用法代码示例。如果您正苦于以下问题:C++ LOCK_CONTENDED函数的具体用法?C++ LOCK_CONTENDED怎么用?C++ LOCK_CONTENDED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOCK_CONTENDED函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _raw_spin_lock_nest_lock
void __lockfunc _raw_spin_lock_nest_lock(raw_spinlock_t *lock,
struct lockdep_map *nest_lock)
{
preempt_disable();
spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
}
示例2: down_read_nested
void down_read_nested(struct rw_semaphore *sem, int subclass)
{
might_sleep();
rwsem_acquire_read(&sem->dep_map, subclass, 0, _RET_IP_);
LOCK_CONTENDED(sem, __down_read_trylock, __down_read);
rwsem_set_reader_owned(sem);
}
示例3: _write_lock_irqsave
unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock)
{
unsigned long flags;
local_irq_save(flags);
preempt_disable();
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
return flags;
}
示例4: _spin_lock_irq
//在单CPU的系统中,进入临界区代码只需要关闭中断就可以了,
//而多CPU的系统中,还需要测试自旋锁的状态
void __lockfunc _spin_lock_irq(spinlock_t *lock)
{
local_irq_disable();//关闭中断
//关闭进程抢占,由于中观或系统调用之后,可能会调度其他进程运行
//(例如当前进程时间片用完,或者有一个拥有更高优先级的进程已经进入了就绪状态),
//preempt_disable()关闭调度器的这个功能,从而保证当前进程在执行临界区代码的过程中不会被其他进程干扰
preempt_disable();
spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
//其实就是调用_raw_spin_lock()函数。#define LOCK_CONTENDED(_lock, try, lock) lock(_lock)
LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
}
示例5: _raw_spin_lock_nested
void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
{
preempt_disable();
spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
}