Jump to content

DosTmrQueryTime: Difference between revisions

From EDM2
Created page with "==Description== Provides a snapshot of the time from the IRQ0 high resolution timer (Intel 8254). ==Syntax== <PRE> #define INCL_DOSPROFILE #include <os2.h> PQWORD pqwTmrT..."
 
Ak120 (talk | contribs)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
Provides a snapshot of the time from the IRQ0 high resolution timer (Intel 8254). Queries the performance timer for a time value.
Provides a snapshot of the time from the IRQ0 high resolution timer (Intel 8254).


==Syntax==
==Syntax==
<PRE>
  DosTmrQueryTime(pqwTmrTime);
#define INCL_DOSPROFILE
#include <os2.h>
 
PQWORD    pqwTmrTime; /*  Time. */
APIRET    rc;          /*  Return Code. */
 
rc = DosTmrQueryTime(pqwTmrTime);


</PRE>
==Parameters==
==Parameters==
; pqwTmrTime (PQWORD) - output : Time.
;pqwTmrTime (PQWORD) - output : Time.
A snapshot of the time from the IRQ0 high resolution timer.
A snapshot of the time from the IRQ0 high resolution timer.
It is a pointer, supplied by the calling application, to the following structure:
typedef struct _QWORD {
          [[ULONG]] ulLo,
          ULONG ulHi,
      } QWORD;
typedef QWORD *PQWORD;


==Return Code==
==Return Code==
  rc (APIRET) - returns
  rc (APIRET) - returns
DosTmrQueryTime returns the following values:
* 0 NO_ERROR
* 87 ERROR_INVALID_PARAMETER
* 53 ERROR_TMR_NO_DEVICE
* 99 ERROR_DEVICE_IN_USE
* 536 ERROR_TMR_INVALID_TIME


DosTmrQueryTime returns the following values:
==Example Source Code==
Use Example:
<PRE>
/*
  * Description: Display high resolution system time.
  */
#define INCL_DOS
#define INCL_DOSERRORS
#include <os2.h>
#include <stdio.h>
VOID main() {
    QWORD qwTime;
    ULONG rc;


* 0        NO_ERROR  
    if ((rc = DosTmrQueryTime(&qwTime)) != NO_ERROR)
* 87       ERROR_INVALID_PARAMETER
          printf("\nERROR (DosTmrQueryTime): %d\n", rc);
* 53        ERROR_TMR_NO_DEVICE
       else
* 99        ERROR_DEVICE_IN_USE
          printf("Time = 0x %08lx %08lx\n", qwTime.ulHi, qwTime.ulLo);
* 536      ERROR_TMR_INVALID_TIME
}
</PRE>


==Remarks==
==Remarks==
This API will fill the QWORD structure, supplied by the caller, with the 64-bit timer value such that :
*pqwTime->ulHi = The most significant 32-bits of the timer value.
*pqwTime->ulLo = The least significant 32-bits of the timer value.
The performance timer is a free running counter; it is initialized to 0 at boot time and thereafter increments. When it reaches its maximum value of (2¬64 - 1), it rolls over to 0 and continues incrementing. A process can time an event by subtracting the value of the timer at the start of the event from the value of the timer at the end of the event. Currently, ulTimerFreq = 1.19318 Mhz, for a timer resolution of about .838 microseconds. (See also [[DosTmrQueryFreq]].) 


==Example Code==
<PRE>
</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosDevConfig|CPI:DosDevConfig]]
* [[DosDevConfig]]
* [[OS2 API:CPI:DosDevIOCtl|CPI:DosDevIOCtl]]
* [[DosDevIOCtl]]
* [[OS2 API:CPI:DosPhysicalDisk|CPI:DosPhysicalDisk]]
* [[DosPhysicalDisk]]
 
* [[DosTmrQueryFreq]]


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 19:45, 5 February 2024

Provides a snapshot of the time from the IRQ0 high resolution timer (Intel 8254). Queries the performance timer for a time value.

Syntax

DosTmrQueryTime(pqwTmrTime);

Parameters

pqwTmrTime (PQWORD) - output
Time.

A snapshot of the time from the IRQ0 high resolution timer.

It is a pointer, supplied by the calling application, to the following structure:

typedef struct _QWORD { 
         ULONG ulLo,
         ULONG ulHi,
     } QWORD;
typedef QWORD *PQWORD;

Return Code

rc (APIRET) - returns

DosTmrQueryTime returns the following values:

  • 0 NO_ERROR
  • 87 ERROR_INVALID_PARAMETER
  • 53 ERROR_TMR_NO_DEVICE
  • 99 ERROR_DEVICE_IN_USE
  • 536 ERROR_TMR_INVALID_TIME

Example Source Code

Use Example:

 /*
  * Description: Display high resolution system time.
  */
 
 #define INCL_DOS
 #define INCL_DOSERRORS
 
 #include <os2.h>
 #include <stdio.h>
 
 VOID main() { 
    QWORD qwTime;
    ULONG rc;

    if ((rc = DosTmrQueryTime(&qwTime)) != NO_ERROR)
          printf("\nERROR (DosTmrQueryTime): %d\n", rc);
       else 
          printf("Time = 0x %08lx %08lx\n", qwTime.ulHi, qwTime.ulLo);
 }

Remarks

This API will fill the QWORD structure, supplied by the caller, with the 64-bit timer value such that :

  • pqwTime->ulHi = The most significant 32-bits of the timer value.
  • pqwTime->ulLo = The least significant 32-bits of the timer value.

The performance timer is a free running counter; it is initialized to 0 at boot time and thereafter increments. When it reaches its maximum value of (2¬64 - 1), it rolls over to 0 and continues incrementing. A process can time an event by subtracting the value of the timer at the start of the event from the value of the timer at the end of the event. Currently, ulTimerFreq = 1.19318 Mhz, for a timer resolution of about .838 microseconds. (See also DosTmrQueryFreq.)

Related Functions