文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ch05-Concurrency and Race Conditions

ch05-Concurrency and Race Conditions

时间:2010-08-09  来源:guocai_yao

The include file that defines semaphores and the operations on them.

#include <asm/semaphore.h>


Two macros for declaring and initializing a semaphore used in mutual exclusion  mode.

DECLARE_MUTEX(name);
DECLARE_MUTEX_LOCKED(name);


Lockand unlocka semaphore. down puts the calling process into an uninterruptible sleep if need be; down_interruptible, instead, can be interrupted by a signal. down_trylock does not sleep; instead, it returns immediately if the  semaphore is unavailable. Code that locks a semaphore must eventually unlock  it with up.

void down(struct semaphore *sem);
int down_interruptible(struct semaphore *sem);
int down_trylock(struct semaphore *sem);
void up(struct semaphore *sem);


The reader/writer version of semaphores and the function that initializes it.

struct rw_semaphore;
init_rwsem(struct rw_semaphore *sem);


Functions for obtaining and releasing read access to a reader/writer semaphore.

void down_read(struct rw_semaphore *sem);
int down_read_trylock(struct rw_semaphore *sem);
void up_read(struct rw_semaphore *sem);


Functions for managing write access to a reader/writer semaphore.

void down_write(struct rw_semaphore *sem)
int down_write_trylock(struct rw_semaphore *sem)
void up_write(struct rw_semaphore *sem)
void downgrade_write(struct rw_semaphore *sem)


The include file describing the Linux completion mechanism, and the normal  methods for initializing completions. INIT_COMPLETION should be used only to  reinitialize a completion that has been previously used.

#include <linux/completion.h>
DECLARE_COMPLETION(name);
init_completion(struct completion *c);
INIT_COMPLETION(struct completion c);


Wait for a completion event to be signalled.

void wait_for_completion(struct completion *c);


Signal a completion event. complete wakes, at most, one waiting thread, while  complete_all wakes all waiters.

void complete(struct completion *c);
void complete_all(struct completion *c);


Signals a completion event by calling complete and calls exit for the current  thread.

void complete_and_exit(struct completion *c, long retval);


The include file defining the spinlockinterface and the two ways of initializing  locks.

#include <linux/spinlock.h>
spinlock_t lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(spinlock_t *lock);


The various ways of locking a spinlock and, possibly, disabling interrupts.

oid spin_lock(spinlock_t *lock);
void spin_lock_irqsave(spinlock_t *lock, unsigned long flags);
void spin_lock_irq(spinlock_t *lock);
void spin_lock_bh(spinlock_t *lock);


Nonspinning versions of the above functions; these return 0 in case of failure to  obtain the lock, nonzero otherwise.

int spin_trylock(spinlock_t *lock);
int spin_trylock_bh(spinlock_t *lock);


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载