码迷,mamicode.com
首页 > 系统相关 > 详细

linux常用的锁及信号量的提取

时间:2015-03-16 19:23:15      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:

1.信号量( 两个进程之间同步)
struct semaphore power_sem;
sema_init(&pdata->power_sem,1);
down(&pdata->power_sem);
up(&pdata->power_sem);


2.互斥量

struct mutex led_mutex;
mutex_init(&led_mutex);
mutex_lock(&led_mutex);
while(t--);// for delay
mutex_unlock(&led_mutex);
mutex_destroy(&led_mutex);

3.wakup锁:
static struct wake_lock ec43_wlock;
wake_lock_init(&ec43_wlock, WAKE_LOCK_SUSPEND, "ec43_wakelock");
wake_lock_timeout(&ec43_wlock, msecs_to_jiffies(10*1000));
//等于上面 wake_lock_timeout(&ec43_wlock, 10*HZ);
wake_lock_destroy(&ec43_wlock);

linux常用的锁及信号量的提取

标签:

原文地址:http://blog.csdn.net/liuxd3000/article/details/44309623

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!