/***************************************************************************** * APPLICATION: _2_03b * MODULE: main * PURPOSE: * AUTHOR(S): damian.galczynski * * 5/11/2017 4:25:24 PM Created. *****************************************************************************/ #include #include #include "auxfunctions.h" /***************************************************************************** * THE MAIN ENTRY POINT TO THE PROGRAM. * * input: argc The number of arguments of the programme. * argv The vector of arguments of the programme. * return: The code of the reason the process was terminated for. * The value defaults to zero. *****************************************************************************/ DWORD WINAPI threadA(void* params); int main(int argc, char* argv[]) { HANDLE WINAPI hThread; DWORD tid = GetCurrentThreadId(); hThread = CreateThread(NULL, 0, threadA, NULL, 0, &tid); if (hThread) { printf("Press any key to stop ...\n"); getchar(); CloseHandle(hThread); } return 0; } DWORD WINAPI threadA(void* params) { const DWORD pid = GetCurrentProcessId(); const DWORD tid = GetCurrentThreadId(); const DWORD timeDeley = getDelayTime(); DWORD exitCode; int timeRemain; randomize(); timeRemain = getRunningTime(THRT_MIN, THRT_MAX); printf("(EXE-2.03b)Watek A : %05lu:%05lu: Watek wystartowal. \n", pid, tid); printf(" Opoznienie: %d\n", timeDeley); printf(" Czas Startu: %d\n", timeRemain); do { printf("(EXE-2.03b)Watek A : %05lu:%05lu: %d\n", pid, tid, timeRemain); Sleep(timeDeley); timeRemain = timeRemain - timeDeley; } while (timeRemain > 0); exitCode = makeCode(); printf("(EXE-2.03B)Watek A : %05lu:%05lu: Code: %lu""\n", pid, tid, exitCode); return exitCode; }