|
From: Per W. <pw...@ia...> - 2006-06-07 06:25:19
|
The 18.2Hz clock interrupt is normally not used.
First of all, it is only 18.2Hz in MS-DOS. It can be reprogrammed to
generate other frequencies too. The 18.2 Hz is an overflow of a 65536
times faster clock used to refresh the memory.
Even if using the 18.2 Hz tick for basic time counting, the "lost" 16 bits
can be read and used to compute the us part, and the internal counter
ticks at more than 1 MHz.
But note that there are more timers available in the PC hardware. It is
possible to use a spare timer to generate a faster clock - most OS uses a
tick counter faster than 18.2 Hz for task switching.
For timing, the best source of high-resolution time are the performance
counters available in Pentium-class processors. One of the performance
counters counts clock-cycles of uptime. This counter is often used to
write code profiling tools.
/Per W
On Tue, 6 Jun 2006, Roger Furer wrote:
> Sorry I whoopsed. Devide to get minutes: 4000 sec /60 = 66.667 min /60 =
> 1.111... hr. So yes multiply by 1000000 for microseconds. 4000 *
> 1000000 = 4 * 10^9 microseconds.
>
> Note that you need to be counting a 1MHz signal to get microsecond
> resolution.
>
> I don't know how much has changed, but in the days of DOS the clock
> interrupt occured at something like 18.5 milliseconds; making
> microsecond resolution so granular it wasn't even milliseconds.
> Roger
>
> Per Westermark wrote:
> > I don't know what minutes have to do with this.
> >
> > Note that the timeval struct splitted the information into two fields,
> > since a 32-bit unsigned integer can't hold more than 4000 seconds in
> > us-resolution.
> >
> > Since gettimeofday() stores very large numbers in the sec field - seconds
> > since 1970-01-01 00:00, you will get overflow if working with 32-bit
> > numbers. Either you should adjust your times based on the startup time of
> > your application, or you should perform the evaluation using a larger data
> > type. long long or __int64 should make sure that the information will fit
> > even if using a 32-bit processor.
> >
> > Note also that the granularity of the usec field will depend on used
> > hardware.
> >
> > /Per W
> >
> > On Tue, 6 Jun 2006, Roger Furer wrote:
> >
> >
> >>microseconds = seconds / 1000000
> >>I don't know if the value you are retrieving is accurate to that degree
> >>of precision, but you must devide. Remember, seconds * 60 = minutes.
> >>Aloha,
> >>Roger
> >>
> >>David Chu wrote:
> >>
> >>>Hi All,
> >>>
> >>>I've a question on how to convert struct timeval into microsecond.
> >>>
> >>>#include <sys/time.h>
> >>>struct timeval {
> >>> time_t sec;
> >>> suseconds_t usec;
> >>>};
> >>>
> >>>What I'm doing right now is the follow:
> >>>
> >>>struct timeval currentTime;
> >>>long timeInLong;
> >>>
> >>>gettimeofday(¤tTime, 0);
> >>>
> >>>// converts sec to microseconds
> >>>timeInLong = currentTime.tv_sec * 1000000;
> >>>
> >>>// Adds the microsecond together with the converted second.
> >>>timeInLong += sendTime.tv_usec;
> >>>
> >>>Does this look correct to you guys?
> >>>
> >>>Thanks,
> >>>
> >>>David
> >>>
> >>>
> >>>------------------------------------------------------------------------
> >>>
> >>>_______________________________________________
> >>>Dev-cpp-users mailing list
> >>>Dev...@li...
> >>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> >>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >>
> >>
> >>
> >>
> >>
> >>_______________________________________________
> >>Dev-cpp-users mailing list
> >>Dev...@li...
> >>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> >>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >>
> >
> >
> >
> >
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
>
>
>
|