1、mutex(互斥信号量)

mutex_init(&mutex);

mutex_lock(&mutex);、mutex_unlock(&mutex);


2、semaphore (信号量)

void sema_init (struct semaphore *sem, int val);

void down(struct semaphore * sem);

int down_interruptible(struct semaphore * sem);

void up(struct semaphore * sem);


3、rw_semaphore (读写信号量)

void init_rwsem(struct rw_semaphore *sem);

void down_read(struct rw_semaphore *sem);

void down_write(struct rw_semaphore *sem);

void up_read(struct rw_semaphore *sem);

void up_write(struct rw_semaphore *sem);





4、Spanlock(自旋锁)

spin_lock_init(x)、DEFINE_SPINLOCK(x)、SPIN_LOCK_UNLOCKED

spin_is_locked(x)、spin_unlock_wait(x)、spin_trylock(lock)

spin_lock(lock)、spin_unlock(lock)

spin_lock_irqsave(lock, flags)、spin_unlock_irqrestore(lock, flags)

spin_lock_irq(lock)、spin_unlock_irq(lock)

spin_lock_bh(lock)、spin_unlock_bh(lock)

spin_trylock_irqsave(lock, flags)

spin_trylock_irq(lock)


5、seqlock(顺序锁)


6、rwlock (读写锁)

rwlock_init(x)

read_trylock(lock)

write_trylock(lock)

read_lock_irqsave(lock, flags)

write_lock_irqsave(lock, flags)

read_unlock_irqrestore(lock, flags)

write_unlock_irqrestore(lock, flags)


7、RCU(read-copy-update)


8、BKL(大内核锁) // to be deleted



Logo

更多推荐