// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. /*============================================================ ** ** Source : test.c ** ** Purpose: InterlockedDecrement() function ** ** The test case spawns MAX_THREADS Threads, and each thread call InterlockedDecrement Function to decrement a ** global counter REPEAT_COUNT Times. The Test case sets the global counter to MAX_THREADS * REPEAT_COUNT ** at the begining of the test. The test cases passes if at the end the test the value of the global counter is Zero. ** ** **=========================================================*/ #include #define MAX_THREADS 64 #define REPEAT_COUNT 10000 LONG GlobalCounter = 0; void DecrementCounter(void); int __cdecl main(int argc, char *argv[]) { LONG TotalOperations=0; int i=0; DWORD dwThreadID = 0; HANDLE hThread[MAX_THREADS]; TotalOperations = MAX_THREADS * REPEAT_COUNT; GlobalCounter = TotalOperations; /* * Initialize the PAL and return FAILURE if this fails */ if(0 != (PAL_Initialize(argc, argv))) { return FAIL; } //Create MAX_THREADS threads that will operate on the global counter for (i=0;i