郭子兴有后人吗:如何运行这个程序

来源:百度文库 编辑:高考问答 时间:2024/04/28 11:46:26
原代码太长,请问在vc++里如何运行呢?就是那个thread.dat是如何设置的?
#include “windows.h”
#include <conio.h>
#include <stdlib.h>
#include <fstream.h>
#include <io.h>
#include <string.h>
#include <stdio.h>
#define READER 'R' //读者
#define WRITER 'W' //写者
#define INTE_PER_SEC 1000 //每秒时钟中断的数目
#define MAX_THREAD_NUM 64 //最大线程数
#define MAX_FILE_NUM 32 //最大文件数目数
#define MAX_STR_LEN 32 //字符串的长度
int readcount=0; //读者数目
int writecount=0; //写者数目
CRITICAL_SECTION RP_Write; //临界资源
CRITICAL_SECTION cs_Write;
CRITICAL_SECTION cs_Read;
struct ThreadInfo{
int serial; //线程序号
char entity; //线程类别(判断是读者还是写者线程)
double delay; //线程延迟时间
double persist; //线程读写操作时间
};

/////////////////////////////////////////////////////
//主函数
int main(int argc,char *argv[]){
char ch;
while(true){
printf("*************************************\n");
printf(" 1.Reader Priority\n");
printf(" 2.Writer Priority\n");
printf(" 3.Exit to Windows\n");
printf("*************************************\n");
printf("Enter your choice(1,2,3): ");
do{
ch=(char)_getch();
}while(ch!='1'&&ch!='2'&&ch!='3');
system("cls");
if(ch=='3')
return 0;
else if(ch=='1')
ReaderPriority("thread.dat");
else
WriterPriority("thread.dat");
printf("\nPress Any Key to Coutinue:");
_getch();
system("cls");
}
return 0;
}

thread.dat 这个用记事本打开看看