--- os2sdk/demos/examples/timer/timer.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/timer/timer.c 2018/08/09 12:26:09 1.1.1.2 @@ -1,77 +1,81 @@ -/* This example illustrates the use of the following 286DOS functions: - * DOSTIMERSTART, DOSTIMERASYNC, DOSTIMERSTOP, DOSSLEEP +/* This example illustrates the use of the following MS OS/2 functions: + * DosTimerStart, DosTimerAsync, DosTimerStop, DosSleep * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 */ -#include /* contains 286DOS function declarations */ +#define INCL_DOSPROCESS +#define INCL_DOSDATETIME +#define INCL_DOSSEMAPHORES + +#include +#include #define SEMNAME "\\SEM\\SOMESEM" /* name of semaphore */ -#define NOEXCLUSIVE 1 /* ownership of semaphore not exclusive */ #define TIMERINTERVAL 1000L /* timer interval */ #define ASYNCINTERVAL 2000 /* asynchronous timer interval */ #define NOTIMEOUT -1 /* no timeout */ -#define BEEPFREQUENCY 400 /* frequency parameter to DOSBEEP */ -#define BEEPDURATION 50 /* duration parameter to DOSBEEP */ +#define BEEPFREQUENCY 400 /* frequency parameter to DosBeep */ +#define BEEPDURATION 50 /* duration parameter to DosBeep */ main () { - unsigned long SemHandle; /* storage for semaphore handle */ - unsigned TimerHandle; /* handle returned by DosTimerStart*/ + HSEM SemHandle; /* storage for semaphore handle */ + HTIMER TimerHandle; /* handle returned by DosTimerStart*/ /* create a system semaphore */ - DOSCREATESEM (NOEXCLUSIVE, &SemHandle, SEMNAME); + DosCreateSem (CSEM_PUBLIC, &SemHandle, SEMNAME); /* - * DOSTIMERSTART/STOP - these functions provide a repetitive + * DosTimerStart/Stop - these functions provide a repetitive * asynchronous timer which clear a semaphore at a specified interval. */ - DOSSEMSET (SemHandle); /* set the system semaphore */ + DosSemSet (SemHandle); /* set the system semaphore */ /* set the interval timer */ - DOSTIMERSTART (TIMERINTERVAL, SemHandle, &TimerHandle); + DosTimerStart (TIMERINTERVAL, SemHandle, &TimerHandle); /* normally, application would do some work in here */ - DOSSEMWAIT (SemHandle, (long) NOTIMEOUT); /* wait on the semaphore */ - DOSBEEP (BEEPFREQUENCY, BEEPDURATION); /* beep when done */ - DOSTIMERSTOP (TimerHandle); /* stop the interval timer */ + DosSemWait (SemHandle, (long) NOTIMEOUT); /* wait on the semaphore */ + DosBeep (BEEPFREQUENCY, BEEPDURATION); /* beep when done */ + DosTimerStop (TimerHandle); /* stop the interval timer */ /* - * DOSTIMERASYNC example. This function provides a one-shot + * DosTimerAsync example. This function provides a one-shot * asynchronous timer which clears a specified semaphore after * a specified time delay. */ - DOSSEMSET (SemHandle); /* set the system semaphore */ + DosSemSet (SemHandle); /* set the system semaphore */ /* start the asynchronous timer */ - DOSTIMERASYNC ((long) ASYNCINTERVAL, SemHandle, &TimerHandle); + DosTimerAsync ((long) ASYNCINTERVAL, SemHandle, &TimerHandle); /* normally, application would do some work in here */ - DOSSEMWAIT (SemHandle, (long) NOTIMEOUT); /* wait on the semaphore */ - DOSBEEP (BEEPFREQUENCY, BEEPDURATION); /* beep when done */ + DosSemWait (SemHandle, (long) NOTIMEOUT); /* wait on the semaphore */ + DosBeep (BEEPFREQUENCY, BEEPDURATION); /* beep when done */ /* - * DOSTIMERSTOP is used to cancel either type of timer. After using + * DosTimerStop is used to cancel either type of timer. After using * this function you must put the semaphore back into a known state * if you need to use it again. Example of cancelling a timer: */ - DOSSEMSET (SemHandle); /* set the system semaphore */ + DosSemSet (SemHandle); /* set the system semaphore */ /* start the asynchronous timer (specify a long time) */ - DOSTIMERASYNC ((long) (10*ASYNCINTERVAL), SemHandle, &TimerHandle); + DosTimerAsync ((long) (10*ASYNCINTERVAL), SemHandle, &TimerHandle); - DOSTIMERSTOP (TimerHandle); /* stop the asynchronous timer */ - DOSSEMCLEAR (SemHandle); /* clear the system semaphore */ - DOSCLOSESEM (SemHandle); /* close the system semaphore */ + DosTimerStop (TimerHandle); /* stop the asynchronous timer */ + DosSemClear (SemHandle); /* clear the system semaphore */ + DosCloseSem (SemHandle); /* close the system semaphore */ /* - * DOSSLEEP - simple synchronous suspend for specified interval. + * DosSleep - simple synchronous suspend for specified interval. */ - DOSSLEEP(TIMERINTERVAL); - DOSBEEP (BEEPFREQUENCY, BEEPDURATION); /* beep when done */ + DosSleep(TIMERINTERVAL); + DosBeep (BEEPFREQUENCY, BEEPDURATION); /* beep when done */ }