os.time overflow - Script Writing - CHDK Forum

os.time overflow

  • 2 Replies
  • 303 Views
os.time overflow
« on: 30 / January / 2019, 03:13:12 »
Advertisements
Can the following script come to an overflow so that the loop hangs forever?


Code: [Select]
z        = 0
shots    = 99999
interval = 3000
t1=os.time()
repeat
  if os.difftime(os.time(),t1)>=0 then
    t1=os.time()+interval
    z=z+1
    shoot()
  end
until z==shots
M100 100a, M3 101a, 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 2*S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

*

Offline reyalp

  • ******
  • 12059
Re: os.time overflow
« Reply #1 on: 30 / January / 2019, 17:01:00 »
Can the following script come to an overflow so that the loop hangs forever?

I don't think it should, within reason*. According to the documentation I wrote when I implemented the os lib:
Quote
os.difftime: Just returns (unsigned int)t1 - (unsigned int)t2
So, the result shouldn't be negative unless the *difference* exceeds 2^31 seconds.

* os.time is seconds since 1970 similar to a unix timestamp, so camera time calculations including CHDK Lua will be affected by the Y2038 bug.
« Last Edit: 31 / January / 2019, 17:04:51 by reyalp »
Don't forget what the H stands for.

Re: os.time overflow
« Reply #2 on: 31 / January / 2019, 04:35:49 »
* os.time is seconds since 1970 similar to a unix timestamp, so camera time calculations including CHDK Lua will be affected by the Y2038 bug.
Thanks, then I have some time left ...  :)
M100 100a, M3 101a, 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 2*S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

 

Related Topics