freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

實(shí)驗(yàn)指導(dǎo)書word版(編輯修改稿)

2024-09-17 20:32 本頁面
 

【文章內(nèi)容簡介】 DLE h_Mutex2。 h_Mutex2=CreateMutex(NULL,FALSE,mutex2)。HANDLE h_Mutex3。 h_Mutex3=CreateMutex(NULL,FALSE,mutex3)。 //線程對(duì)象的數(shù)組 HANDLE h_Thread[MAX_THREAD_NUM]。 ThreadInfo thread_info[MAX_THREAD_NUM]。 readcount=0。 //初始化readcount writecount=0。 //初始化writecount InitializeCriticalSection(amp。cs_Write)。 //初始化臨界區(qū) InitializeCriticalSection(amp。cs_Read)。 ifstream inFile(file)。 //ifstream inFile。 //(file)。 //打開文件 printf(writer Priority:\n\n)。 ///////////////while(inFile) while(inFile) { //讀入每一個(gè)讀者、寫者的信息 inFilethread_info[n_thread].serial。 inFilethread_info[n_thread].entity。 inFilethread_info[n_thread].delay。 inFilethread_info[n_thread++].persist。 ()。 } for(int i=0。i(int)(n_thread)。i++) {if(thread_info[i].entity==READER || thread_info[i].entity==39。r39。) { //創(chuàng)建讀者線程 // h_Thread[i]=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) (RP_ReaderThread),amp。thread_info[i],0,amp。thread_ID)。 h_Thread[i]=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) (WP_ReaderThread),amp。thread_info[i],0,amp。thread_ID)。 } else { //創(chuàng)建寫者線程 // h_Thread[i]=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) (RP_WriterThread),amp。thread_info[i],0,amp。thread_ID)。 h_Thread[i]=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) (WP_WriteThread),amp。thread_info[i],0,amp。thread_ID)。 } } //等待所有線程結(jié)束 wait_for_all=WaitForMultipleObjects(n_thread,h_Thread,TRUE,1)。 printf(All Reader and writer have finished operationg.\n)。 }int main(int argc,char *argv[]){ char ch。 while(true) {//打印提示信息 printf( ==========================================\n)。 printf( ==== 讀者寫者實(shí)驗(yàn)?zāi)M ====\n\n)。 printf( ==========================================\n)。 printf(\n)。 printf( ***********************************\n)。 printf( 1:Reader Priority\n)。 printf( 2:Write Priority\n)。 printf( 3:Exit to Windows\n)。 printf( ***********************************\n)。 printf( Enter your choice(3):\n)。 //如果輸入信息不正確,繼續(xù)輸入 do{ ch=(char)_getch()。 }while(ch!=39。139。amp。amp。ch!=39。239。amp。amp。ch!=39。339。)。 /*system(cls)。*/ //選擇3,返回 if(ch==39。339。) return 0。 //選擇1,讀者 if(ch==39。139。) ReaderPriority()。 //選擇2,寫者優(yōu)先 else WriterPriority()。 //結(jié)束 printf(\n press any key to continue:)。 _getch()。 /*system(cls)。*/ } return 0。} 附錄二、哲學(xué)家就餐問題// : Defines the entry point for the console application.include include include include include include iostreamusing namespace std。const unsigned int PHILOSOPHER_NUM=5。const char THINKING=1。const char HUNGRY=2。const char DINING=3。// each fork has a semaphoreHANDLE semph[PHILOSOPHER_NUM]。// Mutex for printingHANDLE mutex。void philosopherProc(void* param)。int main(int argc, char* argv[]){ int i。 srand(time(0))。 mutex = CreateMutex(NULL, false, NULL)。 for (i=0。 iPHILOSOPHER_NUM。 i++) { semph[i] = CreateSemaphore(NULL, 1, 1, NULL)。 _beginthread(philosopherProc, 0, (void*)amp。i)。 Sleep(10)。 } Sleep(2000)。 return 0。}void philosopherProc(void* param){ int myid。 char idStr[128]。 char stateStr[128]。 char mystate。 int ret。 unsigned int leftFork。 unsigned int rightFork。 myid = *((int*)(param))。 itoa(myid, idStr, 10)。 //cout philosopher myid begin...... endl。 Sleep(10)。 // initial state is THINKING mystate = THINKING。 leftFork = (myid) % PHILOSOPHER_NUM。 rightFork = (myid + 1) % PHILOSOPHER_NUM。 while (true) { switch(mystate) { case THINKING: // changing my state mystate = HUNGRY。 strcpy(stateStr, HUNGRY)。 break。 case HUNGRY: strcpy(stateStr, HUNGRY)。 // first test the left fork ... ret = WaitForSingleObject(semph[leftFork], 0)。 if (ret == WAIT_OBJECT_0) { // left fork is ok, take it up ! // then test the right fork ... ret = WaitForSingleObject(semph[rightFork], 0)。 if (ret == WAIT_OBJECT_0) { // right fork is also ok ! // changing my state mystate = DINING。 strcpy(stateStr, DINING)。 } else { // right fork is being used by others, so I must put down // the left fork. ReleaseSemaphore(semph[leftFork], 1, NULL)。 } } break。 case DINING: // put down both the left and right fork ReleaseSemaphore(semph[leftFork], 1, NULL)。 ReleaseSemaphore(semph[rightFork], 1, NULL)。 // changing my state mystate = THINKING。 strcpy(stateStr, THINKING)。 break。 } // print my state WaitForSingleObject(mutex, INFINITE)。 cout philosopher myid is : stateStr endl。 ReleaseMutex(mutex)。 // sleep a random time : between 1 5 s int sleepTime。 sleepTime = 1 + (int)(*rand()/(RAND_MAX+))。 Sleep(sleepTime*10)。 }} 附錄三、調(diào)度算法模擬include define getjcb(type) (type*)malloc(sizeof(type))define NULL 0int n=0,time=0。float eti,ewi。struct jcb{ char name[10]。 /* 作業(yè)名 */ char state。 /* 作業(yè)狀態(tài) */ int ts。 /* 提交時(shí)間 */ float super。 /* 優(yōu)先權(quán) */ int tb。 /* 開始運(yùn)行時(shí)間 */ int tc。 /* 完成時(shí)間 */ float ti。 /* 周轉(zhuǎn)時(shí)間 */ float wi。 /* 帶權(quán)周轉(zhuǎn)時(shí)間 */ int ntime。 /* 作業(yè)所需運(yùn)行時(shí)間 */ char resource[10]。 /* 所需資源 */ struct jcb *link。 /* 結(jié)構(gòu)體指針 */ } *p,*q,*head=NULL。typedef struct jcb JCB。inital(){int i。printf(\nInput jcb num\n)。scanf(%d,amp。n)。printf(Input\nname\tts\tntime\tresource\n)。for(i=0。in。i++){ p=getjcb(JCB)。 scanf(%s\t%d\t%d\t%s,amp。pname,amp。pts,amp。pntime,amp。presource)。 pstate=39。W39。 plink=NULL。 if(head==NULL) head=q=
點(diǎn)擊復(fù)制文檔內(nèi)容
醫(yī)療健康相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1