c语言线程的创建实验报告,程序实验:-多线程编程---实验报告

62e50291a81fc54b507f33cb80033297.gif 程序实验:-多线程编程---实验报告

(20页)

63cea99a61199d1f0b7ba8d6a998e581.gif

本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!

17.90 积分

嵌入式操作系统—多线程-实验报告 (11-多线程编程)程序实验二:程序实验二:11-多线程编程实验多线程编程实验专业班级专业班级 实验日期实验日期 5.21 姓名姓名 学号学号 实验一(实验一(p284::11-thread.c))1、软件功能描述、软件功能描述创建 3 个线程,让 3 个线程重用同一个执行函数,每个线程都有 5次循环,可以看成 5 个小任务,每次循环之间会有随即等待时间(1-10s)意义在于模拟每个任务到达的时间是随机的没有任何的特定规律。2、程序流程设计、程序流程设计3.部分程序代码注释.部分程序代码注释(关键函数或代码关键函数或代码)#include嵌入式操作系统—多线程-实验报告 (11-多线程编程)#include #include #define T_NUMBER 3#define P_NUMBER 5#define TIME 10.0void *thrd_func(void *arg ){int thrd_num=(int)arg;int delay_time =0;int count =0;printf(“Thread %d is staraing\n“,thrd_num);for(count=0;count #include #include#define THREAD_NUMBER 3 /*线程数*/ #define REPEAT_NUMBER 3 /*每个线程的小任务数*/ #define DELAY_TIME_LEVELS 10.0 /*小任务间的最大时间间隔*/ pthread_mutex_t mutex; void *thrd_func(void *arg) //线程函数例程 {int thrd_num = (int)arg; int delay_time = 0, count = 0; int res; //互斥锁上锁res = pthread_mutex_lock( if(res){嵌入式操作系统—多线程-实验报告 (11-多线程编程)printf(“Thread %d is starting\n“, thrd_num); pthread_exit(NULL); }printf(“Thread %d is starting\n“, thrd_num); for(count = 0; count #include #include #include#define THREAD_NUMBER3 #define REPEAT_NUMBER 3 #define DELAY_TIME_LEVELS 10.0 sem_t sem[THREAD_NUMBER]; 嵌入式操作系统—多线程-实验报告 (11-多线程编程)void *thrd_func(void *arg) { int thrd_num = (int)arg; int delay_time = 0; int count = 0; sem_wait( printf(“Thread %d is starting\n“,thrd_num); for(count = 0; count = 0; no--) { res = pthread_join(thread[no], if(!res) { printf(“Thread %d joined\n“, no); 嵌入式操作系统—多线程-实验报告 (11-多线程编程)} else { printf(“Thread %d join failed\n“, no); } sem_post( } for(no = 0; no #include #include#define REPEAT_NUMBER 3 #define DELAY_TIME_LEVELS 10.0 int finish_flag = 0; void *thrd_func(void *arg) {嵌入式操作系统—多线程-实验报告 (11-多线程编程)int delay_time = 0; int count = 0; printf(“Th is starting\n“); for(count=0; count #include #include嵌入式操作系统—多线程-实验报告 (11-多线程编程)#include #include #include #include #include#define MYFIFO“myfifo“ #defineBUFFER_SIZE3 #defineUNIT_SIZE5 #defineRUN_TIME30 #defineDELAY_TIME_LEVELS5.0int fd; time_t end_time; sem_t mutex,full,avail; void *producer(void *arg) { int real_write; int delay_time=0; while(time(NULL)

524d6daf746efaa52c3c71bbfe7ba172.gif  天天文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值