]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/commit
MFC r203760: Improve time precision for grdc(6):
authordelphij <delphij@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 12 Mar 2010 00:51:13 +0000 (00:51 +0000)
committerdelphij <delphij@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 12 Mar 2010 00:51:13 +0000 (00:51 +0000)
commit88ffae63259481873e588075d00c368be47849d4
tree43f72bef5ae265e8e9ec770ab0fbae042c6ad7a7
parentae394aa7df8c2b772b2356b201a9e1edb1120dfd
MFC r203760: Improve time precision for grdc(6):

Traditionally, grdc would obtain time through time(3) which in turn gets
only the second part of clock (CLOCK_SECOND), and sleep for 1 second after
each screen refresh.

This approach would have two problems.  First, we are not guaranteed to
be waken up at the beginning of a whole second, which will typically
exhibit as a "lag" on second number.  Second, because we sleep for whole
second, and the refresh process would take some time, the error would
accumulate from time to time, making the lag variable.

Make grdc(6) to use time(3) to get time only at the beginning, and sample
time in CLOCK_REALTIME_FAST granularity after refreshing, and use the
nanosecond part to caculate how much time we want to sleep.

PR: bin/120813

git-svn-id: svn://svn.freebsd.org/base/stable/8@205056 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
games/grdc/grdc.c