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

全部博文(383)

文章存档

2011年(1)

2010年(9)

2009年(276)

2008年(97)

我的朋友
博文列表
标题:
标题 阅读 评论 转发 发布日期
使用 /proc 文件系统来访问 Linux 内核的内容 453 0 0 2008-12-04
系统调用跟我学(3) 622 0 0 2008-12-04
系统调用跟我学(2) 552 0 0 2008-12-04
系统调用跟我学(1) 483 0 0 2008-12-04
Per-CPU变量学习笔记 915 0 0 2008-12-03
成功白领需要“十商” 745 0 0 2008-12-03
关于FS寄存器的资料 1668 0 0 2008-12-03
在内核中操作文件释疑 899 0 1 2008-12-03
在内核中对文件进行读写 755 0 0 2008-12-03
AT&T汇编语言 1967 0 0 2008-12-03
linux内核空间与用户空间信息交互方法 550 0 0 2008-12-03
关于Linux系统内核源代码分析经验谈 495 0 0 2008-12-03
人生哲理 615 0 0 2008-12-02
内核编译(内核2.6.9-55到2.6.26) 1395 0 0 2008-12-02
读Linux源码小技巧 548 0 0 2008-12-01
好习惯 1581 0 0 2008-12-01
给主人留下些什么吧!~~

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

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

登录 注册