亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? maintest.cpp

?? 處理機調度
?? CPP
字號:
#include "Ulti.h"
#include "PCB.h"
#include "EQueue.h"
#include "GraphAlgorithm.h"
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <math.h>

#define DEBUG 1

char *inFileName="inputData.txt";
char *outFileName="outputData.txt";

int bRun;
long WINAPI WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
void  stiProcessMag(HDC  hdc);
void IntToChar(int intData,char* inChar);
HWND hWndMain;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);



//program starting.
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
	MSG   msg;
	if(!InitWindowsClass(hInstance))
		return FALSE;
	
	if(!InitWindows(hInstance,nCmdShow))
		return FALSE;
	
	//Core message looping
	while(GetMessage(&msg,NULL,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam;

}

//main wndProc function: message looping
long WINAPI WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
	HDC hDC;
	HBRUSH hBrush;
	HPEN hPen;
	PAINTSTRUCT PtStr;

	switch(iMessage)
	{
		case WM_PAINT:
			//First draw,a black line
			hDC=BeginPaint(hWnd,&PtStr);
			hPen=(HPEN)GetStockObject(NULL_PEN);//get empty brush
			SelectObject(hDC,hPen);
			hBrush=(HBRUSH)GetStockObject(BLACK_BRUSH);
			SelectObject(hDC,hBrush);
			
			hPen=CreatePen(PS_SOLID,2,RGB(255,0,0));//create pen
			SelectObject(hDC,hPen);		
			


			stiProcessMag(hDC);
		
			DeleteObject(hPen);
			DeleteObject(hBrush);
			EndPaint(hWnd,&PtStr);
			
		
			//MessageBox(hWnd,"HelloWorld!","Msg Box",MB_OK);
			return 0;
		case WM_DESTROY:
			PostQuitMessage(0);
			return 0;
		default:
			return DefWindowProc(hWnd,iMessage,wParam,lParam);
				
	}
}

//Init the Window to show out.
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
	HWND hWnd;
	hWnd=CreateWindow("WinFill",
				"進程調度摸擬程序圖示",
					WS_OVERLAPPEDWINDOW,
				CW_USEDEFAULT,
				0,
				CW_USEDEFAULT,
				0,
				NULL,	
				NULL,
				hInstance,
				NULL	
			    );
	if(!hWnd)
		return FALSE;
	hWndMain=hWnd;
	ShowWindow(hWnd,nCmdShow);
	UpdateWindow(hWnd);
	return TRUE;
}

//Set wndClass Propertity
BOOL InitWindowsClass(HINSTANCE hInstance)
{
	WNDCLASS wndClass;

	wndClass.cbClsExtra=0;
	wndClass.cbWndExtra=0;
	wndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
	wndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
	wndClass.hIcon=LoadIcon(NULL,"END");
	wndClass.hInstance=hInstance;
	wndClass.lpfnWndProc=WndProc;
	wndClass.lpszClassName="WinFill";
	wndClass.lpszMenuName=NULL;
	wndClass.style=CS_HREDRAW|CS_VREDRAW;
	
	return RegisterClass(&wndClass);
}

void stiProcessMag(HDC  hDC)
{
	/*--------Open file--------*/
	FILE* inputFile;
	FILE* outputFile;
	int bDelay;

	/*=--------creation part-------*/
	char mode;
	int numOfThread; 
	PCBList pcbList,p;
	ptrPCBNode tmpNode;
	/*--------main process-------*/
	pQueue readyQueue,endQueue;
	ptrProcess runProcess,tmpProcess;

	int count;
	int delayTime;
	DWORD result=0;


	if((inputFile=fopen(inFileName,"rb"))==NULL)
	{	
		printf("open inputFile error\n");
		return ;
	}
	
	if((outputFile=fopen(outFileName,"wb"))==NULL)
	{
		printf("open outputFile error\n");
		return ;
	}
			
		printf("oepn files success \n");
	
	/*Create the PCB Table*/

	
	/*create a pcbList with a null head.*/	
	pcbList=(ptrPCBNode)malloc(sizeof(struct PCBNode));
	p=pcbList;

	fscanf(inputFile,"mode=%c\r\n",&mode);
	fscanf(inputFile,"numOfThread=%d\r\n",&numOfThread);
	fscanf(inputFile,"delay=%d\r\n",&bDelay);
	fscanf(inputFile,"delayTime=%d\r\n",&delayTime);
	printf("------------program init starts------------\n");
	fprintf(outputFile,"------------program init starts------------\r\n");
//	int mCount=0;
	char tmpChar[10];
	int x0,y0,height;
	int x1,width;

	x0=10;
	y0=60;
	x1=100;
	height=40;
	width=10;
	int i;
	for(i=0;i<=30;i+=2)
	{
		IntToChar(i,tmpChar);
		TextOut(hDC,x1+i*width,y0-height-5,tmpChar,strlen(tmpChar));
	}
	

	DDALine(x1,y0-height+15,x1+700,y0-height+15,0,hDC);
	TextOut(hDC,x1+600,y0-20,"T",1);
	TextOut(hDC,x0+14,y0-height-5,"Pri SevTime",strlen("Pri SevTime"));

	if(mode=='0')/*Read process definition from the file*/
		{
 					/*Creation with input list*/
					int i;
					for(i=0;i<numOfThread;i++)
					{
							tmpNode=(ptrPCBNode)malloc(sizeof(struct PCBNode));
							fscanf(inputFile,"%d,%d,%s\r\n",&tmpNode->priorityNum,&tmpNode->remainSecs,tmpNode->processName);	
							tmpNode->processName[strlen(tmpNode->processName)]='\0';
							tmpNode->processID=i;
							tmpNode->staturs=STA_READY;
							
							if(tmpNode->remainSecs>0)
							{
									p->next=tmpNode;
									p=p->next;
									
									strcpy(tmpChar,"P");
									tmpChar[1]=48+i;
									tmpChar[2]='\0';
									TextOut(hDC,x0,y0+height*i,tmpChar,strlen(tmpChar));
									
									IntToChar(tmpNode->priorityNum,tmpChar);
									TextOut(hDC,x0+22,y0+height*i,tmpChar,strlen(tmpChar));
								
									IntToChar(tmpNode->remainSecs,tmpChar);
									TextOut(hDC,x0+40,y0+height*i,tmpChar,strlen(tmpChar));

			printf("ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Ready\n",tmpNode->processID,tmpNode->processName,tmpNode->priorityNum,tmpNode->remainSecs);
			fprintf(outputFile,"ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Ready\r\n",tmpNode->processID,tmpNode->processName,tmpNode->priorityNum,tmpNode->remainSecs);

							}	
					}
					p->next=NULL;//Correction: add this to has effects in sort algorithm
			
		}
	else if(mode=='1')
		{
					int i;
					srand((unsigned int)time (NULL));
					
					for(i=0;i<numOfThread;i++)
					{
							tmpNode=(ptrPCBNode)malloc(sizeof(struct PCBNode));
								
							tmpNode->priorityNum=(int)eRandom(10);
							
							tmpNode->remainSecs=(int)eRandom(10);
							
							tmpNode->processID=i;
							
							strcpy(tmpNode->processName,"Process");
							tmpNode->processName[7]=48+i;
							tmpNode->processName[8]='\0';

							tmpNode->staturs=STA_READY;
							
							
							if(tmpNode->remainSecs>0)
							{
									p->next=tmpNode;
									p=p->next;
									
									strcpy(tmpChar,"P");
									tmpChar[1]=48+i;
									tmpChar[2]='\0';
									TextOut(hDC,x0,y0+height*i,tmpChar,strlen(tmpChar));
									//mCount++;

									IntToChar(tmpNode->priorityNum,tmpChar);
									TextOut(hDC,x0+22,y0+height*i,tmpChar,strlen(tmpChar));
								
									IntToChar(tmpNode->remainSecs,tmpChar);
									TextOut(hDC,x0+40,y0+height*i,tmpChar,strlen(tmpChar));
									
			printf("ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Ready\n",tmpNode->processID,tmpNode->processName,tmpNode->priorityNum,tmpNode->remainSecs);
			fprintf(outputFile,"ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Ready\r\n",tmpNode->processID,tmpNode->processName,tmpNode->priorityNum,tmpNode->remainSecs);
							}	
						}
					p->next=NULL;//Correction: add this to has effects in sort algorithm
		}	
	else
		{
			printf("mode is illegal!\n");
			return ;
		}
	printf("------------program init ends------------\n");
	fprintf(outputFile,"------------program init ends------------\r\n");
	/*Sort the pcb table*/		
	sortPCB(pcbList);							//8:56 test ok
	if(DEBUG)printf("sortPCB successfully\n");	
	
	/*init queue*/
	endQueue=createNullQueueWithHead();
	readyQueue=createNullQueueWithHead();
		
	tmpNode=pcbList;
	tmpNode=tmpNode->next;
	
	while(tmpNode!=NULL)						//9:38 test ok
	{
		tmpProcess=(ptrProcess)malloc(sizeof(struct Process));
		tmpProcess->processID=tmpNode->processID;
		tmpProcess->staturs=tmpNode->staturs;
		tmpProcess->priorityNum=tmpNode->priorityNum;
		tmpProcess->remainSecs=tmpNode->remainSecs;
		strcpy(tmpProcess->processName,tmpNode->processName);
		enQueue(readyQueue,tmpProcess);
		tmpNode=tmpNode->next;
	}
	
	if(DEBUG)printf("create readyQueue successfully\n");
	runProcess=NULL;
	/*The core of process management*/
	printf("------------start of main simulation program------------\n");
	fprintf(outputFile,"------------start of main simulation program------------\r\n");
	count=0;
	while(!isEmpty(readyQueue)||runProcess!=NULL)
	{
		if(bDelay)
			Sleep(delayTime);
		//	eDelay(delayTime);/*DELAY 1 SECS*/
		
		if(runProcess!=NULL)
			{
			count++;
			
			MoveToEx(hDC,x1,y0+runProcess->processID*height,NULL);
			x1+=width;
			LineTo(hDC,x1,y0+runProcess->processID*height);
			
	printf("Line:%d ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Running\n",count,runProcess->processID,runProcess->processName,runProcess->priorityNum,runProcess->remainSecs);
	fprintf(outputFile,"Line:%d ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Running\r\n",count,runProcess->processID,runProcess->processName,runProcess->priorityNum,runProcess->remainSecs);
					runProcess->priorityNum++;
					runProcess->remainSecs--;
					
					if(runProcess->remainSecs==0)/*if time use out,end the process*/
						{
							runProcess->staturs=STA_END;
							enQueue(endQueue,runProcess);
							updatePCBList(pcbList,runProcess);
							count++;
	printf("Line:%d ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Ends\n",count,runProcess->processID,runProcess->processName,runProcess->priorityNum,runProcess->remainSecs);
	fprintf(outputFile,"Line:%d ProcessID:%d,Name:%s,Priority:%d,RemainSecs:%d Staturs: Ends\r\n",count,runProcess->processID,runProcess->processName,runProcess->priorityNum,runProcess->remainSecs);
						}
					else if(!isEmpty(readyQueue))
						{
							runProcess->staturs=STA_READY;
							insert(readyQueue,runProcess);
							updatePCBList(pcbList,runProcess);	
						}
			}
		
		/*apply new mem for the new node*/
		//Correction:runProcess!=NULL should be placed at front
		if(runProcess!=NULL&&runProcess->remainSecs==0)//for the last thread consult.&& runProcess!=firstNode(NULL)
			runProcess=NULL;
		
		if(!isEmpty(readyQueue))
		{
			runProcess=(ptrProcess)malloc(sizeof(struct Process));	
			/*wake up a new thread*/	
			runProcess=deQueue(readyQueue);
			runProcess->staturs=STA_RUN;
			updatePCBList(pcbList,runProcess);
		}

		if(count>90)
			break;
	}//10:03 test ok
	printf("------------end of main simulation program------------\n");
	fprintf(outputFile,"------------end of main simulation program------------\r\n");

	fclose(inputFile);
	fclose(outputFile);

	printf("program ends successfully\n");
	getchar();
	
	bRun=0;
	return;
	//return ;
}

//only convert plus data to minus data
void IntToChar(int intData,char* inChar)
{
		int tmpData;
		int i,len;
		/*
		if(inChar==NULL)
			MessageBox(hWnd,"in IntToChar,in Char is null\n!","Warning!",MB_OK);
		if(inData<0)
			MessageBox(hWnd,"in IntToChar,inData is minus\n!","Warning!",MB_OK);
		*/
		if(intData<10)
			len=1;
		else if(intData<100)
			len=2;
		else if(intData<1000)
			len=3;
		else if(intData<10000)
			len=4;
		else 
			len=5;
		
		i=len-1;
		while(i>=0)
		{
			tmpData=48+intData%10;
			inChar[i]=tmpData;
			i--;
			intData/=10;
		}

		inChar[len]='\0';
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久精品一品道一区| 欧美一区二区三区在线观看视频| 暴力调教一区二区三区| 欧美精选在线播放| 国产精品久久福利| 国产一区二区三区日韩| 欧美精品自拍偷拍| 亚洲欧美另类图片小说| 国产福利精品一区| 欧美xfplay| 丝袜美腿成人在线| 在线观看一区二区视频| 国产精品视频九色porn| 九九精品视频在线看| 欧美日韩一区视频| 亚洲精品欧美专区| 成人自拍视频在线| 久久精品一区蜜桃臀影院| 日本麻豆一区二区三区视频| 色菇凉天天综合网| 亚洲欧洲av在线| www.色综合.com| 国产精品私人自拍| 国产麻豆精品久久一二三| 日韩精品影音先锋| 免费人成在线不卡| 日韩一级片在线观看| 日本不卡中文字幕| 欧美一区二区三区在线| 视频在线在亚洲| 欧美一卡二卡在线| 免费成人性网站| 26uuu国产电影一区二区| 韩国一区二区在线观看| 精品国产91亚洲一区二区三区婷婷| 日韩电影免费一区| 日韩一区二区三区在线| 人人超碰91尤物精品国产| 宅男噜噜噜66一区二区66| 天天色综合成人网| 日韩欧美一级二级三级久久久| 日韩av在线播放中文字幕| 日韩一二三区不卡| 国产乱妇无码大片在线观看| 欧美极品少妇xxxxⅹ高跟鞋| 成人国产视频在线观看| 亚洲精品日韩专区silk| 在线电影欧美成精品| 另类欧美日韩国产在线| 日本一区二区成人| 色综合中文综合网| 欧美videossexotv100| 久久99九九99精品| 国产偷国产偷精品高清尤物| 99久久99久久久精品齐齐| 亚洲一区二区欧美日韩| 日韩美女一区二区三区四区| 国产不卡视频一区二区三区| 一区二区三区丝袜| 欧美一区二区三区四区视频 | 日韩久久精品一区| 成人综合在线观看| 亚洲成人av一区二区| 精品久久久久久亚洲综合网 | 欧美日韩色一区| 国产一区不卡精品| 亚洲精品国产第一综合99久久| 欧美日韩第一区日日骚| 国产麻豆视频精品| 亚洲成av人片在www色猫咪| 久久五月婷婷丁香社区| 91福利资源站| 国产高清不卡一区| 日韩激情视频网站| 综合色中文字幕| 欧美xxx久久| 欧美日韩精品一区二区三区四区 | 蜜臀久久久久久久| 亚洲同性gay激情无套| 日韩精品一区二区三区中文精品| 99久久久国产精品免费蜜臀| 日本不卡一区二区三区高清视频| 亚洲色图一区二区| 久久综合狠狠综合| 欧美剧情电影在线观看完整版免费励志电影| 国产在线精品一区二区夜色| 亚洲五码中文字幕| 国产精品久久久久久久久久久免费看| 5月丁香婷婷综合| 91黄色激情网站| 成年人网站91| 国产成人亚洲综合a∨婷婷图片 | 亚洲欧美激情视频在线观看一区二区三区| 91精品国产综合久久福利| 99国产精品国产精品毛片| 国产综合一区二区| 蜜桃视频一区二区三区| 亚洲国产色一区| 综合激情成人伊人| 亚洲国产精品av| 国产婷婷色一区二区三区四区 | 欧美美女黄视频| 色呦呦日韩精品| 99re成人精品视频| 99久久国产综合精品女不卡| 成人一区二区三区在线观看 | 美国欧美日韩国产在线播放| 亚洲成年人网站在线观看| 有码一区二区三区| 亚洲精品一二三| 亚洲一区二区视频在线| 亚洲综合清纯丝袜自拍| 一区二区三区不卡视频 | 日本高清不卡在线观看| 91在线视频18| 一本大道久久a久久精二百| 91蜜桃婷婷狠狠久久综合9色| 成人av在线一区二区| 成人福利在线看| 色综合天天综合网天天狠天天| 色综合久久中文字幕综合网| 91久久奴性调教| 欧美日韩一区二区三区高清| 欧美日韩免费不卡视频一区二区三区| 91麻豆高清视频| 欧美日韩一区不卡| 91.xcao| 欧美精品一区二区在线观看| 久久精品一区二区| 国产精品乱码人人做人人爱| 国产精品二三区| 亚洲高清免费在线| 免费成人结看片| 国产凹凸在线观看一区二区| 99久久精品免费看国产| 欧美日韩一区视频| 精品成人在线观看| 国产精品久久久久久妇女6080| 亚洲自拍偷拍图区| 青青青爽久久午夜综合久久午夜| 极品少妇xxxx精品少妇| 不卡的av在线| 91精品在线免费| 久久久精品国产99久久精品芒果| 欧美国产激情二区三区| 亚洲欧美日韩成人高清在线一区| 天天av天天翘天天综合网色鬼国产 | 蜜桃视频免费观看一区| 成人午夜av影视| 欧美精品 国产精品| 国产婷婷一区二区| 亚洲高清三级视频| 国产一区不卡视频| 欧美午夜精品一区二区蜜桃| 久久久久久久久久久电影| 亚洲精品老司机| 国内精品伊人久久久久av影院| 91免费看片在线观看| 337p日本欧洲亚洲大胆色噜噜| 亚洲三级视频在线观看| 日韩电影在线免费观看| av成人动漫在线观看| 91精品国产色综合久久不卡蜜臀| 中文av一区二区| 久久电影网电视剧免费观看| 91网页版在线| 久久久青草青青国产亚洲免观| 亚洲电影在线播放| 99精品视频一区| 久久久久99精品一区| 亚洲精品美腿丝袜| 国产精品一区二区久激情瑜伽| 欧美午夜不卡视频| 国产精品美女一区二区在线观看| 奇米色一区二区| 欧洲国内综合视频| 中文字幕一区二区三区在线播放 | 日韩视频免费观看高清完整版| 国产精品国产三级国产有无不卡| 久久99精品久久久久婷婷| 色婷婷国产精品| 国产精品你懂的在线| 国产成人在线观看免费网站| 88在线观看91蜜桃国自产| 亚洲综合免费观看高清在线观看| 91在线小视频| 国产精品国产自产拍高清av | 欧美人成免费网站| 有码一区二区三区| 一本色道亚洲精品aⅴ| 国产日韩在线不卡| 国产精品中文字幕一区二区三区| 欧美一级黄色片| 麻豆精品在线观看| 91精品国产欧美一区二区18| 伊人性伊人情综合网| 色综合久久综合中文综合网| 亚洲欧洲综合另类在线| 91在线观看高清| 亚洲天堂av一区|