#include
#include
/*信号量的定义-操作系统兔子吃草-操作系统 - IMDN开发者社群-imdn.cn" />
#include#include/*信号量的定义,它是负责协调各个线程,以保证它们能够正确、合理的使用公共资源。用于控制进程间的同步与互斥*/ typedefHANDLESemaphore; Semaphoreg_semBuffer,g_semGlass,g_mutex;//mutex为互斥锁 //利用Windows下的API函数(视窗操作系统应用程序接口)来定义P、V操作 #defineP(S)WaitForSingleObject(S,INFINITE)#defineV(S)ReleaseSemaphore(S,1,NULL)#definerate1000 #defineCONSUMER_NUM4//消费者个数#definePRODUCER_NUM4//生产者个数#defineBUFFER_NUM4//缓冲区个数 char*thing[4]={"glass1","glass2","glass3","glass4"};//公共的队列缓冲区 structBuffer{ intproduct[BUFFER_NUM]; intfront,rear; }g_buf;//兔子线程DWORDWINAPIRabbit(LPVOIDpara) { inti=*(int*)para;//第i只小白兔&-IMDN开发者社群-imdn.cn">
#include#include/*信号量的定义,它是负责协调各个线程,以保证它们能够正确、合理的使用公共资源。用于控制进程间的同步与互斥*/ typedefHANDLESemaphore; Semaphoreg_semBuffer,g_semGlass,g_mutex;//mutex为互斥锁 //利用Windows下的API函数(视窗操作系统应用程序接口)来定义P、V操作 #defineP(S)WaitForSingleObject(S,INFINITE)#defineV(S)ReleaseSemaphore(S,1,NULL)#definerate1000 #defineCONSUMER_NUM4//消费者个数#definePRODUCER_NUM4//生产者个数#defineBUFFER_NUM4//缓冲区个数 char*thing[4]={"glass1","glass2","glass3","glass4"};//公共的队列缓冲区 structBuffer{ intproduct[BUFFER_NUM]; intfront,rear; }g_buf;//兔子线程DWORDWINAPIRabbit(LPVOIDpara) { inti=*(int*)para;//第i只小白兔& - IMDN开发者社群-imdn.cn">
于 2022-05-23 发布
文件大小:1.15 MB
0 87
#include "stdafx.h"
#include
#include
#include
/*信号量的定义,它是负责协调各个线程, 以保证它们能够正确、合理的使用公共资源。 用于控制进程间的同步与互斥*/
typedef HANDLE Semaphore;
Semaphore g_semBuffer,g_semGlass, g_mutex; //mutex 为互斥锁
// 利用 Windows 下的 API 函数(视窗操作系统应用程序接口)来定义 P、V 操作
#define P(S) WaitForSingleObject(S,INFINITE)
#define V(S) ReleaseSemaphore(S,1,NULL)
#define rate 1000
#define CONSUMER_NUM 4 // 消费者个数
#define PRODUCER_NUM 4 // 生产者个数
#define BUFFER_NUM 4 // 缓冲区个数
char *thing[4]={"glass1","glass2","glass3","glass4"};
//公共的队列缓冲区
struct Buffer
{
int product[BUFFER_NUM];
int front,rear;
}g_buf;
//兔子线程
DWORD WINAPI Rabbit(LPVOID para)
{
int i =*(int*)para; //第 i 只小白兔&
下载说明:请别用迅雷下载,失败请重下,重下不扣分!
dgdf g豆腐干 反对广泛生生世世 事实
dgdf g豆腐干 反对广泛生生世世 事实-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
2022-07-11 06:43:41下载
积分:1
Linux中的不间断数据保护模块实现代码
Linux中的不间断数据保护模块实现代码-Linux uninterrupted data protection module code
2022-03-20 12:20:17下载
积分:1
OMAP730 USB 驱动源码
OMAP730 USB 驱动源码-OMAP730 USB driver source code
2022-03-29 04:57:49下载
积分:1
此文档提供了一些IBM大型机操 作 系 统 AIX的命令,对于AIX入门来说是有一定帮助的。...
此文档提供了一些IBM大型机操作系统AIX的命令,对于AIX入门来说是有一定帮助的。-This document provides a number of IBM mainframe operating system command AIX for AIX is a certain entry help.
2022-06-30 04:46:40下载
积分:1
自己编写的一个程序,开发简单的员工工资信息管理系 统 ,适用与初学JAVA者,实现对选工信息的查询,修改,添加和删除的功能。...
自己编写的一个程序,开发简单的员工工资信息管理系统,适用与初学JAVA者,实现对选工信息的查询,修改,添加和删除的功能。-I have written a program to develop a simple, wages and salaries of information management systems, application and JAVA beginner who realize information on the mode of election workers to access, modify, add and delete functions.
2022-01-23 11:20:12下载
积分:1
请求页式管理中的置换算法
假设有一个用户进程P的地址空间为n(n=60)页,系统已在内存中给该进程分配有m(m
2023-01-30 14:15:04下载
积分:1
可带操 作 系 统 或者不需要操 作 系 统 即可使用的SD卡的源代码!
可带操作系统或者不需要操作系统即可使用的SD卡的源代码!-May bring the operating system or operating system does not need to use the SD card source code!
2022-02-14 01:10:53下载
积分:1
jsp development of office software, you can run tomcat where
jsp开发的办公软件,可以在tomcat那里运行-jsp development of office software, you can run tomcat where
2022-11-11 01:10:04下载
积分:1
Assembly Language (Assembly Language) is a computer professional in an importan...
《汇编语言》(Assembly Language)是计算机专业中一门重要的基础课程,是一种面向机器的低级语言。它依赖于硬件,能通过巧妙的程序设计充分发挥硬件的潜力。汇编语言程序产生的代码运行效率高。因此,到目前为止,许多软件系统(例如操作系统等)的核心部分仍然用汇编语言来编写。- Assembly Language (Assembly Language) is a computer professional in an important foundation courses, is a low-level language-oriented machines. It depends on the hardware, through clever programming and give full play to the hardware s potential. Assembly language code generated by running the procedures and high efficiency. Hence, up to now, many software systems (such as operating systems, etc.) is still the core of the assembly language used to write.
2022-08-17 08:18:05下载
积分:1
bankers algorithm, against textbook example of the Solution
银行家算法,针对课本例子的求解-bankers algorithm, against textbook example of the Solution
2022-03-02 01:30:47下载
积分:1