home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / samprog2.zip / DOSTMR.INF (.txt) < prev    next >
OS/2 Help File  |  1993-08-16  |  4KB  |  101 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. DosTmrQueryTime ΓòÉΓòÉΓòÉ
  3.  
  4. Queries the performance timer for a time value. Calling Sequence 
  5.  
  6. DosTmrQueryTime (pqwTime) 
  7.  
  8. Parameters 
  9.  
  10. pqwTime (@OTHER) - A pointer, supplied by the calling application, to the 
  11. following structure: 
  12.  
  13.    typedef struct _QWORD {
  14.       ULONG ulLo,
  15.       ULONG ulHi,
  16.    } QWORD;
  17.    typedef QWORD *PQWORD;
  18.  
  19. Returns 
  20.  
  21. o No Error 
  22. o ERROR_INVALID_PARAMETER - The QWORD structure could not be written to. 
  23. o ERROR_TMR_NO_DEVICE - This indicates that the timer device driver was not 
  24.   installed 
  25. o ERROR_DEVICE_IN_USE - This indicates that there are multiple processes 
  26.   attempting to use the 8254 hardware device in a conflicting manner. 
  27. o ERROR_TMR_INVALID_TIME 
  28.  
  29. Remarks 
  30.  
  31. This API will fill the QWORD structure, supplied by the caller, with the 64-bit 
  32. timer value such that : 
  33.  
  34.    pqwTime->ulHi = The most significant 32-bits of the timer value. 
  35.  
  36.    pqwTime->ulLo = The least significant 32-bits of the timer value. 
  37.  
  38. The performance timer is a free running counter; it is initialized to 0 at boot 
  39. time and thereafter increments.  When it reaches its maximum value of (2╨║64 - 
  40. 1), it rolls over to 0 and continues incrementing.  A process can time an event 
  41. by subtracting the value of the timer at the start of the event from the value 
  42. of the timer at the end of the event.  Currently, ulTimerFreq = 1.19318 Mhz, 
  43. for a timer resolution of about .838 microseconds.  (See also DosTmrQueryFreq.) 
  44.  
  45.  
  46. ΓòÉΓòÉΓòÉ 2. DosTmrQueryFreq ΓòÉΓòÉΓòÉ
  47.  
  48. Queries the performance timer for its frequency. 
  49.  
  50. Calling Sequence 
  51.  
  52. DosTmrQueryFreq (pulTmrFreq) 
  53.  
  54. Parameters 
  55.  
  56. pulTmrFreq (@DWORD) - A pointer, supplied by the the calling application, to a 
  57. ULONG which is to be filled with the timer frequency. 
  58.  
  59. Returns 
  60.  
  61. o No Error 
  62. o ERROR_INVALID_PARAMETER - The parameter could not be written to. 
  63. o ERROR_TMR_NO_DEVICE - This indicates that the timer device driver was not 
  64.   installed 
  65. o ERROR_DEVICE_IN_USE - This indicates that there are multiple processes 
  66.   attempting to use the 8254 hardware device in a conflicting manner. 
  67.  
  68. Remarks 
  69.  
  70. Currently, the timer frequency = 1.19318 Mhz, for a timer resolution of about 
  71. .838 microseconds. (See also DosTmrQueryTime.) 
  72.  
  73.  
  74. ΓòÉΓòÉΓòÉ 3. Samples ΓòÉΓòÉΓòÉ
  75.  
  76.   /*
  77.   * Description: Display high resolution system time.
  78.   *
  79.   *
  80.   */
  81.  
  82.  #define INCL_DOS
  83.  #define INCL_DOSERRORS
  84.  
  85.  #include <os2.h>
  86.  #include <stdio.h>
  87.  
  88.  VOID
  89.  main()
  90.  {
  91.    QWORD qwTime;
  92.    ULONG rc;
  93.  
  94.      if ((rc = DosTmrQueryTime(&qwTime)) != NO_ERROR)
  95.          printf("\nERROR (DosTmrQueryTime): %d\n", rc);
  96.      else
  97.          printf("Time = 0x %08lx %08lx\n",
  98.              qwTime.ulHi, qwTime.ulLo);
  99.  
  100.  }
  101.