flat assembler
Message board for the users of flat assembler.

Index > Windows > why invoke gettickcount in opengl demo?

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
a115433



Joined: 05 Mar 2010
Posts: 144
a115433 18 Mar 2010, 15:41
you have no way of knowing what time elapsed since previous call, so you can handle possible error.
Quote:
There is GetTickCount64() (Vista/2008+) as well. Wink

yeah function has the same flaw, only it takes little longer, and its vista+ what disqualify it from general programming.
Post 18 Mar 2010, 15:41
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Mar 2010, 16:07
a115433,

Aha, 2³² times longer (Good catch! Universe probably collapse significantly before the overflow. Wink). What are you proposing, infinite precision tick counter? Wink

Pretend to be an astronomer and use Julian dates. Wink
Post 18 Mar 2010, 16:07
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 18 Mar 2010, 16:17
Quote:

only it takes little longer

Little? WTF, little???

Well, no one felt tempted to answer your previous questions so here they go:

>And you think this 50 days is really 50 days?
No, it is ~49.71 days.

>What if i change frequency of power supply, so realtime clock will go faster?
Power supply frequency? Is this CPU frequency maybe? The real-time clock has little to do with this AFAIK, here it is used the PIT/APIC timer (or whatever is used in modern PCs) to keep the counting. Probably some error still exists but I would be very surprised if it is too gross.

>What if i do something with clock itself?
GetTickCount spec would be violated, it has to count milliseconds, not whatever a naughty driver decided by changing the hardware timer without notifying the kernel. The same applies to processors supporting a fixed rate TSC, some driver could reset the counter making the illusion that hundreds years passed in a matter of nanoseconds.

>What if i manage to get on top secret military server, hang the application between GetTickCount() exactly -1 microseconds, so both calls return same value? And the next code will behave diffrently after it? For example divide by 0 (maybe in module responsible for logging statistics)?
No one will notice in 50 days that? Then I'm very thankful of the "design error", those guys really deserve the crash for those tons of incompetence.
Post 18 Mar 2010, 16:17
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Mar 2010, 16:21
LocoDelAssembly,

What if god wakes from the eternal sleep and ~universe before the second call to GetTickCount()? That will ruin the entire algorithm! Wink

"They've killed Kenny!" — "You bastards!" Wink


Last edited by baldr on 18 Mar 2010, 16:27; edited 1 time in total
Post 18 Mar 2010, 16:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20570
Location: In your JS exploiting you and your system
revolution 18 Mar 2010, 16:26
Yeah! We need GetTickCount4294967296(). I won't settle for anything less.
Post 18 Mar 2010, 16:26
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Mar 2010, 16:30
revolution,

About to have "that doesn't compute" error. Quantum states of all particles in the universe don't seem to hold such a counter. Wink Yet there is a probability that I don't count them properly.
Post 18 Mar 2010, 16:30
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 18 Mar 2010, 16:33
Laughing
Post 18 Mar 2010, 16:33
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Mar 2010, 16:39
Limits are as such, limits. When you don't care about them, they're striking back.
Post 18 Mar 2010, 16:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20570
Location: In your JS exploiting you and your system
revolution 18 Mar 2010, 16:55
baldr wrote:
revolution,

About to have "that doesn't compute" error. Quantum states of all particles in the universe don't seem to hold such a counter. Wink Yet there is a probability that I don't count them properly.
It only takes 512MB to store a 4Gb number.
Post 18 Mar 2010, 16:55
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Mar 2010, 17:10
revolution,

Damn, I thought about 2↑↑32. That happens.
Post 18 Mar 2010, 17:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20570
Location: In your JS exploiting you and your system
revolution 19 Mar 2010, 07:14
baldr wrote:
Damn, I thought about 2↑↑32. That happens.
Can we assume "↑" means this?

If so, then that is an awfully big number! We could count sub-yocto-yocto-yocto-yocto-Planck times and still not run out of bits to count with for the foreseeable future.
Post 19 Mar 2010, 07:14
View user's profile Send private message Visit poster's website Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 19 Mar 2010, 08:22
revolution wrote:
baldr wrote:
Damn, I thought about 2↑↑32. That happens.
Can we assume "↑" means this?

If so, then that is an awfully big number!
It's awfully small. There were already MUCH bigger numbers. Wink
Post 19 Mar 2010, 08:22
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 19 Mar 2010, 08:49
getdatetimetick()

maybe it can be better.

with the format like this:
YYYY/MM/DD ; hh:mm:ss:tick
16bits/4bits/5bits ; 5bits/6bits/6bits/10bits
then, without any problem, i can say only 52bits are largelly enough to gettickcount until the year 65536.
assuming tick resolution is 1millisecond and year starting at jesus birth.

when getting time, don't forget to get the date, to see if there are overflows.

thats what i name good coding.
Post 19 Mar 2010, 08:49
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 19 Mar 2010, 08:58
revolution,

Yes, that's D. E. Knuth arrow. I thought of it first because such counter will probably satisfy a115433's needs.

__________
Fanael,

Is Graham's number big enough? Wink

__________
edfed,

B.C. dates should be available too. What about year 0? Wink
Post 19 Mar 2010, 08:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20570
Location: In your JS exploiting you and your system
revolution 19 Mar 2010, 09:18
edfed wrote:
... until the year 65536.
Years 32,768 and 65,536
Post 19 Mar 2010, 09:18
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 19 Mar 2010, 10:01
lol, we can troll about that a very long time, at least 30757 more years

Laughing
Post 19 Mar 2010, 10:01
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 19 Mar 2010, 10:07
baldr wrote:
There is GetTickCount64() (Vista/2008+)


Smile Anyone dares to test my BUG.EXE ?? Preferably on Vista running for > 50 days without reboot Smile Post shot Idea
Post 19 Mar 2010, 10:07
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 19 Mar 2010, 10:35
baldr wrote:
Fanael,

Is Graham's number big enough? Wink
Nope. It's of course big, but it is very small compared to other answers. Wink
Post 19 Mar 2010, 10:35
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 19 Mar 2010, 13:10
lol, win98 cannot gives years over 2099 and under 1985.
i cannot creates files at my day of born.
and if i live that long, i hope i'll have my own OS. Laughing

what i like on this board is that we don't stop to feed the trolls, we feed him so much that he becomes ill and fed up. Laughing mouarffff
Post 19 Mar 2010, 13:10
View user's profile Send private message Visit poster's website Reply with quote
a115433



Joined: 05 Mar 2010
Posts: 144
a115433 19 Mar 2010, 14:08
nonononono
resolution is not important!
make 100 functions GetTickCount(), GetTickCount2(), GetTickCount4(), etc...

But let each of them return error in case of overflow!

Quote:
>And you think this 50 days is really 50 days?
No, it is ~49.71 days.

GetTickCount() has the resolution of unsigned 32 bits, that is:
4294967295 miliseconds
wich is 4294967 (+ .295) seconds
its 1193 (+ .0464708(3)) hours. since x86 allow only 32 bits, (3) is rounded down to 3.
1193 (+ .04647083) hours
and it is 49.71026961791(6). since (6) cant fit into limited register, round up to 7, and we have maximum abbount of days that can pass between 2 effective (actual read from counter) calls of GetTickCount() = 49.710269617917 days. And thats assuming in calculations we used modulo from DX.
Post 19 Mar 2010, 14:08
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.