--- os2sdk/demos/examples/suspend/suspend.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/suspend/suspend.c 2018/08/09 12:26:15 1.1.1.2 @@ -1,8 +1,8 @@ /* - * Example of DOSSUSPENDTHREAD/DOSRESUMETHREAD usage. + * Example of DosSuspendThread/DosResumeThread usage. * - * DOSSUSPENDTHREAD can be used to ensure mutual exclusion when a thread - * knows by number all the other thread which might try to access the + * DosSuspendThread can be used to ensure mutual exclusion when a thread + * knows by number all the other threads which might try to access the * shared resource. * * In this example the main thread can call printf() freely because it @@ -26,10 +26,14 @@ * * compile as: cl -Gs -AL -G2 -Lp suspend.c * + * Created by Microsoft Corp. 1986 */ -#include -#include +#define INCL_DOSPROCESS +#define INCL_SUB + +#include +#include #include "stdio.h" #include "malloc.h" #define STACK_SIZE 1024 @@ -40,36 +44,36 @@ int flag; void main() { char *stkptr; - unsigned thread_id; + TID thread_id; register int i; /* obtain pointer to the END of a block of memory */ stkptr = (char *)malloc(STACK_SIZE) + STACK_SIZE - 1; /* create another thread */ - DOSCREATETHREAD(f_thread, &thread_id, stkptr); + DosCreateThread(f_thread, &thread_id, stkptr); for(i = 0; i < 20; i++) { - DOSSUSPENDTHREAD(thread_id); /* suspend the subthread */ + DosSuspendThread(thread_id); /* suspend the subthread */ printf("the main thread has suspended thread %u\n", thread_id); - DOSSLEEP(3000L); + DosSleep(3000L); /* resume the subthread */ printf("now resuming the suspended thread\n"); - DOSRESUMETHREAD(thread_id); + DosResumeThread(thread_id); - DOSSLEEP(3000L); + DosSleep(3000L); } - DOSEXIT(1, 0); /* exit all threads */ + DosExit(EXIT_PROCESS, 0); /* exit all threads */ } void f_thread() { while (1) { - DOSENTERCRITSEC(); - VIOWRTTTY("subthread running\r\n", 19, 0); - DOSEXITCRITSEC(); - DOSSLEEP(300L); + DosEnterCritSec(); + VioWrtTTy("subthread running\r\n", 19, 0); + DosExitCritSec(); + DosSleep(300L); } }