(此文档为word格式,下载后您可任意编辑修改!)
多核编程与并行计算实验报告
姓名:
日期:2014年 4月20日
实验一
exa1.cpp : Defines the entry point for the console application. #include \() { }
int i=0;
_beginthread(ThreadFunc1,0,NULL); _beginthread(ThreadFunc2,0,NULL); Sleep(3000); cout<<\< 实验二 exa2.cpp : Defines the entry point for the console application. #include \ 0; } DWORD WINAPI FunTwo(LPVOID param){ while(true) { Sleep(1000); cout<<\; } return 0; } int main(int argc, char* argv[]) { int input=0; HANDLE >>input; if(input==1) { } ResumeThread( 0; 实验三 exa3.cpp : Defines the entry point for the console application. #include \ 0; } int main() { } HANDLE 0; 实验四: exa4.cpp : Defines the entry point for the console application. #include \(int argc , char * argv[]) { } evRead = CreateEvent (NULL ,FALSE ,FALSE ,NULL) ; evFinish = CreateEvent (NULL ,FALSE ,FALSE ,NULL) ; _beginthread(ReadThread , 0 , NULL) ; _beginthread(WriteThread , 0 , NULL) ; WaitForSingleObject (evFinish,INFINITE) ; cout<<\< 实验五 exa5.cpp : Defines the entry point for the console application. #include \[2] ; CRITICAL_SECTION cs ; void WithdrawThread1(LPVOID param) { } void WithdrawThread2(LPVOID param) { EnterCriticalSection(&cs) ; if ( total-20 >= 0) { EnterCriticalSection(&cs) ; if ( total-90 >= 0) { } else cout<<\(&cs) ; SetEvent (evFin[0]) ; total -= 90 ; cout<<\<