--- os2sdk/demos/examples/dosexit/dosexit.c 2018/08/09 12:25:13 1.1 +++ os2sdk/demos/examples/dosexit/dosexit.c 2018/08/09 12:26:25 1.1.1.2 @@ -1,29 +1,32 @@ /* - * Example of DOSEXIT usage. + * Example of DosExit usage. * - * DOSEXIT can be used to terminate a specific thread, or all threads in + * DosExit can be used to terminate a specific thread, or all threads in * a process. In general, even if your application has just one thread - * it is very important to use the "all threads" form of DOSEXIT when + * it is very important to use the "all threads" form of DosExit when * your application terminates. This is because you may call some library * package or run under an environment manager which creates threads on * your behalf, which you are not aware of. * - * In this example, the main thread is the first to call DOSEXIT, but calls it + * In this example, the main thread is the first to call DosExit, but calls it * so as to only end the one thread. Whichever of the two remaining threads - * first notices that the flag has been set will then call DOSEXIT and - * terminate the process. If f_thread is the one to call DOSEXIT then + * first notices that the flag has been set will then call DosExit and + * terminate the process. If f_thread is the one to call DosExit then * the process will return an exit code of 1, and if it is g_thread, an * exit code of 2. * - * compile as: cl -Gs -AL -G2 -Lp dosexit.c + * compile as: cl -Gs -AL -G2 -Lp DosExit.c * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 * */ +#define INCL_DOSPROCESS +#define INCL_SUB + +#include +#include #include -#include -#include #define STACK_SIZE 1024 extern void f_thread(void); @@ -33,48 +36,48 @@ int flag; main() { char *stkptr; - unsigned thread_id; + TID thread_id; flag = 0; /* create two subthreads */ stkptr = (char *)malloc(STACK_SIZE) + STACK_SIZE; - DOSCREATETHREAD(f_thread, &thread_id, stkptr); + DosCreateThread(f_thread, &thread_id, stkptr); stkptr = (char *)malloc(STACK_SIZE) + STACK_SIZE; - DOSCREATETHREAD(g_thread, &thread_id, stkptr); + DosCreateThread(g_thread, &thread_id, stkptr); /* let the sub-threads run for a while */ - DOSSLEEP(500L); + DosSleep(500L); /* exit from this thread only */ printf("main thread is now exiting\n"); flag = 1; - DOSEXIT(0,0); + DosExit(EXIT_THREAD,0); } void f_thread() { /* wait for the global flag to be set */ while (flag == 0) { - VIOWRTTTY("f_thread, still running\r\n", 25, 0); - DOSSLEEP(0L); + VioWrtTTy("f_thread, still running\r\n", 25, 0); + DosSleep(0L); } /* exit this process (all threads) */ - VIOWRTTTY("f_thread, now exiting all\r\n", 27, 0); - DOSEXIT(1,1); + VioWrtTTy("f_thread, now exiting all\r\n", 27, 0); + DosExit(EXIT_PROCESS,1); } void g_thread() { /* wait for the global flag to be set */ while (flag == 0) { - VIOWRTTTY("g_thread, still running\r\n", 25, 0); - DOSSLEEP(0L); + VioWrtTTy("g_thread, still running\r\n", 25, 0); + DosSleep(0L); } /* exit this process (all threads) */ - VIOWRTTTY("g_thread, now exiting all\r\n", 27, 0); - DOSEXIT(1,2); + VioWrtTTy("g_thread, now exiting all\r\n", 27, 0); + DosExit(EXIT_PROCESS,2); }