多核编程与并行计算
实验十一:
// exa11.cpp : Defines the entry point for the console application. //
#include "stdafx.h"
#include <windows.h>
#include <conio.h>
#include <stdio.h>
#define THREAD_INSTANCE_NUMBER 3
LONG g_fResourceInUse = FALSE;
LONG g_lCounter = 0;
CRITICAL_SECTION cs;
DWORD ThreadProc1(void * pData) {
return 0; EnterCriticalSection(&cs); printf("ThreadProc1 %d enters into critical section\n",ThreadNumberTemp); Sleep(1000); LeaveCriticalSection(&cs); int ThreadNumberTemp = (*(int*) pData); printf("ThreadProc1: %d is running!\n",ThreadNumberTemp );