#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 116
#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 只小白兔&
下载说明:请别用迅雷下载,失败请重下,重下不扣分!
关于操 作 系 统 :本程序可选用优先数法或简单轮转法对五个进程进行调度。每个进程处于运行R(run)、就绪W(wait)和完成F(finish)三种状态之一,并假定起...
关于操作系统:本程序可选用优先数法或简单轮转法对五个进程进行调度。每个进程处于运行R(run)、就绪W(wait)和完成F(finish)三种状态之一,并假定起始状态都是就绪状态W。-On the operating system: This procedure may choose to use the priority number of law or simple rotation on the five process scheduling. Each process is running R (run), ready W (wait) and the completion of F (finish), one of three states and assume that the initial state is a state of readiness W.
2022-02-04 17:52:14下载
积分:1
Used for computer and NI
用来实现计算机与NI-GPIB卡的通信,具备读写功能-Used for computer and NI-GPIB card communications, have to read and write functions
2022-12-13 05:35:03下载
积分:1
first
先近先出,时间片轮转,以及优先级的进程调度程序。采用叻C++的编程方法。值得下载。-first-out near first time films rotate, and the process of priority scheduling procedures. Using C++ featuring the programming method. Worth the download.
2022-02-06 11:05:38下载
积分:1
双飞燕a4 双飞燕a4 双飞燕a4 双飞燕a4 双飞燕a4
双飞燕a4 双飞燕a4 双飞燕a4 双飞燕a4 双飞燕a4 -Shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4 shuangfeiyan a4
2022-10-04 14:55:04下载
积分:1
实现磁盘的动态分区,三种算法 有注释
实现磁盘的动态分区,三种算法 有注释-To achieve dynamic disk partition, three kinds of algorithms comment
2023-05-11 22:40:02下载
积分:1
dos 1.0 其中包含quick basic源代码、内存管理himem emm386 发展历史
dos 1.0 其中包含quick basic源代码、内存管理himem emm386 发展历史-dos 1.0 which includes quick basic source code, memory management himem emm386 history
2023-02-04 17:40:08下载
积分:1
Bochs this virtual machine
Bochs这个虚拟机的源代码。学习虚拟机的编写和操作系统的编写有帮助。-Bochs this virtual machine
2023-03-10 11:35:04下载
积分:1
短进程作 业调度
短作业优先级调度,mfc框架,实现短进程优先调度算法,可以运行,应该会有帮助
2022-02-25 20:31:20下载
积分:1
lunix下用c编写malloc函数
lunix下用c编写malloc函数-lunix c prepared using malloc function
2022-04-30 13:07:48下载
积分:1
Windows1.0 【1985年珍藏版】
Windows1.0 【1985年珍藏版】-Windows1.0 1985 01/23/2006 :
2022-01-22 01:55:39下载
积分:1