云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 实验指导书- 处理机调度算法

实验指导书- 处理机调度算法

  • 62 次阅读
  • 3 次下载
  • 2025/12/9 18:17:00

《嵌入式操作系统》实验指导书

}

}

2.4 开发环境与工具

系统平台:LINUX环境 实现语言:C语言 开发工具:NANO编辑器

3数据结构与模块说明

3.1 数据结构

通过分析课程设计要求,定义以下的数据: sem_t

mutex,customers,barbers;

//design

three

mutex,customer,barbers

int waiting=0; //the number of waiting customers int chair[5];

3.2程序模块说明 3.2.1主函数模块

主函数流程图如下:

9

semaphores:

《嵌入式操作系统》实验指导书

3.2.2 理发师模块

理发师模块函数流程图如下:

10

《嵌入式操作系统》实验指导书

3.2.3 顾客模块

顾客模块函数流程图如下:

4源程序

4.1用户名、源程序名和目标程序名

用户名:rj070234

源程序名:SleepingBarber.c 目标程序名:SleepingBarber 主机IP地址:192.168.1.254

11

《嵌入式操作系统》实验指导书

4.2源程序代码

#include #include #include #include #include #include #include

#define n 5 //the shop have five chairs

//design three semaphores: mutex,customer,barbers sem_t mutex,customers,barbers;

int waiting=0; //the number of waiting customers int chair[5]; void * barber();

void * customer(void *arg);

int main(int argc,char *argv[]) {

//create 10 semaphores and one Barber semaphore pthread_t Customer_id[10],Barber_id; int i;

sem_init(&mutex,0,1); //init mutex semaphore to 1 sem_init(&customers,0,0);//init semaphore customers to 0 sem_init(&barbers,0,1);

for(i=0;i<5;i++)

pthread_create(&Barber_id,NULL,(void*)barber,NULL);

12

搜索更多关于: 实验指导书- 处理机调度算法 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

《嵌入式操作系统》实验指导书 } } 2.4 开发环境与工具 系统平台:LINUX环境 实现语言:C语言 开发工具:NANO编辑器 3数据结构与模块说明 3.1 数据结构 通过分析课程设计要求,定义以下的数据: sem_t mutex,customers,barbers; //design three mutex,customer,barbers int waiting=0; //the number of waiting customers int chair[5]; 3.2程序模块说明 3.2.1主函数模块 主函数流程图如下: 9 semaphores: <

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com