Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1897915
  • 博文数量: 383
  • 博客积分: 10011
  • 博客等级: 上将
  • 技术积分: 4061
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-24 18:53
文章分类

全部博文(383)

文章存档

2011年(1)

2010年(9)

2009年(276)

2008年(97)

我的朋友
博文列表
标题:
标题 阅读 评论 转发 发布日期
SUSE下使用bochs调试linux-0.11内核  3225 1 0 2009-05-18
openSUSE 10.3 + Bochs搭建操作系统调试环境。 1722 0 0 2009-05-18
Linux下用bochs调试OS 3325 1 1 2009-05-18
C语言面试题大汇总之华为面试题 1528 0 0 2009-05-15
深入理解sizeof 859 0 0 2009-05-15
如果你懂这40条,你就是圣人 910 2 2 2009-05-15
基于Ubuntu和Bochs:用汇编程序写的BIOS 1714 0 1 2009-05-15
核心模块的加载和用户程序insmod 2516 0 0 2009-05-15
设置PATH环境变量 1461 0 0 2009-05-15
static变量和static函数的用法 1724 0 0 2009-05-14
编写内核驱动的通用Makefile 1620 0 1 2009-05-13
解密中国IT人十大职业现状 980 0 0 2009-05-09
Fedora 8启动时greeter crash的解决方法 1457 0 0 2009-05-04
人是有质地的 1165 0 0 2009-05-04
嵌入式学习指导 2219 3 0 2009-05-04
《我的好兄弟》(小沈阳)歌词 34149 20 0 2009-05-02
c++ 虚函数的实现机制 1928 1 0 2009-04-28
我到底在追求什么?【转载】 1349 1 0 2009-04-27
中国古代34位美女 1275 0 0 2009-04-24
c语言之宏预处理命令 2526 0 0 2009-04-24
给主人留下些什么吧!~~

chinaunix网友2011-06-10 17:35

博主你好, 我想买个笔记本,平常要用CAD、3DMAX、photoshop,但是我不懂电脑配置,麻烦你给说说怎么样的配置才行呀,或者推荐几款笔记本也行,3000元左右。

回复 |  删除 |  举报

chinaunix网友2011-05-23 16:00

博主现在不在了吗?我的QQ: 344831602 ,有很急的问题想请教, 谢谢了!!!

回复 |  删除 |  举报

chinaunix网友2010-07-04 03:36

cwj670@qq.com 670400080@qq.com 谢谢

回复 |  删除 |  举报

chinaunix网友2010-07-04 03:32

#include #include #define BUFFER_SIZE 16 struct prodcons { int buffer[BUFFER_SIZE]; pthread_mutex_t lock; int readpos,writepos; pthread_cond_t notempty; pthread_cond_t notfull; }; void init (struct prodcons *b) { pthread_mutex_init(&b->lock,NULL); pthread_cond_init(&b->notempty,NULL); pthread_cond_init(&b->notfull,NULL); b->readpos=0; b->writepos=0; } void put(struct prodcons *b, int data) { { pthread_mutex_lock(&b->lock); if((b->writepos+1)%BUFFER_SIZE==b->readpos) { pthread_cond_wait(&b->notfull,&b->lock); } b->buffer[b->writepos]=data; b->writepos++; if(b->writepos>=BUFFER_SIZE) b->writepos=0; pthread_cond_signal(&b->notempty); pthread_mutex_unlock(&b->lock); } int get(struct prodcons *b) { int data; pthread_mutex_lock(&b->lock); if(b->writepos==b->readpos) { pthread_cond_wait(&b->notempty,&b->lock); } data=b->buffer[b->readpos]; b->readpos++; if(b->readpos>=BUFFER_SIZE) b->readpos=0; pthread_cond_signal(&b->notfull); pthread_mutex_unlock(&b->lock); return data; } #define OVER (-1) struct prodcons buffer; void *producer(void *data) { int n; for(n=0;n<10000;n++) { printf(“%d---->\n”,n); put(&buffer,n); } put(&buffer,OVER); return NULL; } void *consumer(void *data) { int d; while(1) { d=get(&buffer); if(d==OVER) break; printf(“---->%d\n”,d); } return NULL; } int main(void) { pthread_t th_a,th_b; void *retval; init(&buffer); pthread_create(&th_a,NULL,producer,0); pthread_create(&th_b,NULL,consumer,0); pthread_join(th_a,&retval); pthread_join(th_b,&retval); return 0; } 高人,帮个忙把这段程序加上注释呗,详细的,多谢了

回复 |  删除 |  举报

yanhongkang9282010-05-23 20:46

东北大学的学生,做了一年的ARM9蓝牙开发,想和你交个朋友,QQ1217866355

回复  |  举报
留言热议
请登录后留言。

登录 注册