Chinaunix首页 | 论坛 | 博客
  • 博客访问: 686308
  • 博文数量: 152
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1793
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-12 12:26
个人简介

相信自己,只有不想做的,没有做不到的。

文章分类

全部博文(152)

文章存档

2021年(1)

2015年(2)

2014年(74)

2013年(75)

分类: LINUX

2013-12-12 12:57:34

//信号量
1,定义
struct semaphore sem;

2,初始化
sema_init(&sem,1);

3,获得信号量,释放信号量
static int hello_open (struct inode *inode, struct file *file)

 if(down_trylock(&sem))
  return -EBUSY;
 return 0;
}
static int hello_release (struct inode *inode, struct file *file)
{
 up(&sem);
 printk("call hello release\n");
 return 0;
}


阅读(391) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~