void TestCase15() { DWORD count = 0, wait4, wait5, wait6; // Request ownership of mutex. while (count < 1) { wait4 = WaitForSingleObject(mutexResource4, INFINITE); wait5 = WaitForSingleObject(mutexResource5, INFINITE); wait6 = WaitForSingleObject(mutexResource6, INFINITE); switch (wait4, wait5, wait6) { // The thread got ownership of the mutex case WAIT_OBJECT_0: { StartingFunction(15); // Do not remove - for testing purposes //Using resources resource4++; int iTemp4 = StartToUseResource(4); // Do not remove - for testing purposes //Using resources resource5++; int iTemp5 = StartToUseResource(5); // Do not remove - for testing purposes //Using resources resource6++; int iTemp6 = StartToUseResource(6); // Do not remove - for testing purposes TestCase1(); // Do not remove - for testing purposes TestCase7(); // Do not remove - for testing purposes TestCase6(); // Do not remove - for testing purposes FinishUsingResource(4, iTemp4); // Do not remove - for testing purposes FinishUsingResource(5, iTemp5); // Do not remove - for testing purposes FinishUsingResource(6, iTemp6); // Do not remove - for testing purposes count++; // Release ownership of mutex objects ReleaseMutex(mutexResource4); ReleaseMutex(mutexResource5); ReleaseMutex(mutexResource6); } break; case WAIT_ABANDONED: printf("Wait abandoned\n"); break; } } EndingFunction(15); // Do not remove - for testing purposes }
int main() { TestCase1(); TestCase2(); TestCase3(); return 0; }
void TestCase13() { StartingFunction(13); // Do not remove - for testing purposes TestCase1(); // Do not remove - for testing purposes TestCase7(); // Do not remove - for testing purposes TestCase8(); // Do not remove - for testing purposes EndingFunction(13); // Do not remove - for testing purposes }
// Thread 1 should run this DWORD WINAPI Procedure1(LPVOID lpParm) { InitialCode(1000); // Do not remove - for testing purposes printf("Thread 1 runnning...\n"); for (int i = 0; i < 100; i++) // Do not remove - for testing purposes { // Do not remove - for testing purposes TestCase1(); // Do not remove - for testing purposes RemainderCode(100); // Do not remove - for testing purposes TestCase6(); // Do not remove - for testing purposes RemainderCode(100); // Do not remove - for testing purposes TestCase11(); // Do not remove - for testing purposes RemainderCode(500); // Do not remove - for testing purposes SendDataToServer(1); // Do not remove - for testing purposes printf("Thread 1 data sent\n"); } // Do not remove - for testing purposes return 1; }