#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 100
#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 只小白兔&
下载说明:请别用迅雷下载,失败请重下,重下不扣分!
文章详细分析了核加内核的源代码,希望对大家的研究和分析
这篇文章详细分析了Nucleus PLUS内核的源码,希望对大家有帮助!-The article detailed analysis of the Nucleus PLUS kernel source code, you want to help!
2022-01-26 03:40:01下载
积分:1
设置窗口启用禁用
提供dll和Demo,通过在labview中对该dll的调用,实现对窗口的禁用和启用,而不需通过窗口句柄获取所有控件再进行启用禁用。版本labview2013
2022-01-25 21:57:03下载
积分:1
操 作 系 统 课程设计报告,文件系 统 管理过程
模拟文件系 统 工作 过程,实现文件的存储和删除...
操作系统课程设计报告,文件系统管理过程
模拟文件系统工作过程,实现文件的存储和删除
-Report operating system curriculum design, file system management process simulation process file system, file storage, and delete
2022-11-25 03:30:03下载
积分:1
<自己动手写操 作 系 统 >源代码第4章,其中所有代码都已通过调试,之间包括可运行程序,直接下载到虚拟机上可以运行。...
源代码第4章,其中所有代码都已通过调试,之间包括可运行程序,直接下载到虚拟机上可以运行。- source code, Chapter 4, which have passed all of the code debugging, including operational procedures between the directly downloaded to the virtual machine can run.
2022-08-09 13:51:36下载
积分:1
真正的
实模式操作系统的设计与实现-Real-mode operating system design and implementation. . . . . . . . . . . . . . . . . . .
2022-01-22 05:20:17下载
积分:1
一个小型操 作 系 统 雏形,实现了基本的启动以及基础的内存设备管理功能...
一个小型操作系统雏形,实现了基本的启动以及基础的内存设备管理功能-a small operating system prototype, to achieve the basic infrastructure as well as the start of the memory management functions of equipment
2022-01-31 21:09:48下载
积分:1
minix操 作 系 统 的引导相关程序
minix操作系统的引导相关程序-Minix operating system to guide related procedures
2022-03-18 07:04:57下载
积分:1
此代码为PXA270的EBOOT代码,代码包含了所有启动的信息.
此代码为PXA270的EBOOT代码,代码包含了所有启动的信息.-This code for the PXA270
2022-03-17 14:15:31下载
积分:1
C prepared by the bank ATM system. Function well, not the incidental detail writ...
采用C++编写的银行ATM系统。功能不错,不详细介绍了
附带我们自己写的课程设计报告-C prepared by the bank ATM system. Function well, not the incidental detail write our own curriculum design report
2022-04-20 16:37:34下载
积分:1
操 作 系 统 操 作 系 统 的用户
操作系统
操作系统]
操作系统
消费者-生产者模拟程序-OS operating system] operating system consumer-producer simulation program
2023-02-14 05:45:04下载
积分:1