多核编程与并行计算
实验七
// exa7.cpp : Defines the entry point for the console application. //
#include "stdafx.h"
#include <windows.h>
#include <iostream.h>
#define THREAD_INSTANCE_NUMBER 3
DWORD foo(void * pData) {
}
int main(int argc, char* argv[])
{
cout << "foo: " << ThreadNumberTemp << " is running!" << endl; if ((hSemaphore = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, "Semaphore.Test")) == } cout << "foo " << ThreadNumberTemp << " gets the semaphore"<< endl; ReleaseSemaphore(hSemaphore, 1, NULL); CloseHandle(hSemaphore); return 0; cout << "Open Semaphore error!" << endl; int ThreadNumberTemp = (*(int*) pData); HANDLE hSemaphore; NULL) {