Jump to content
The simFlight Network Forums

Lua ipc.sleep


Recommended Posts

Hello Pete!

I have a question about the Lua ipc.sleep function. I have noticed that longer "sleeps" seems a bit shorter than they should. For instance “a sleep” with a duration of 60 000 ms only lasts about 54 seconds.

First I thought that it might be something wrong with my environment but after have tried it on another computer I can say it behaves the same way.

Any idea about the reason for this?

Thanks for a otherwise excellent product.

Best regards

Bleedin

Link to comment
Share on other sites

I have a question about the Lua ipc.sleep function. I have noticed that longer "sleeps" seems a bit shorter than they should. For instance “a sleep” with a duration of 60 000 ms only lasts about 54 seconds.

They simply call the Windows "sleep()" function, but they do it in a loop with "sleep(9)" interspersed with checks on whether the user (or FSUIPC through an aircraft change) has tried to 'kill' it. Each Sleep(9) is deducted from the total needed by 10, allowing 1 millisecond for process/thread switching and abort testing. This works very well for shorter intervals and on less capable PCs with a lot going on, but on a powerful system with less going in it may induce as much as the 10% difference you've noticed. This might be much more likely on an FS9 installation which loads the PC so much less than FSX.

Do you need great accuracy? I could probably implement an accurate one based on the microsecond timer instead, but for 99.9% of uses this is over the top, and would certainly result in a minimum delay of more than the current code allows.

I won't be changing FSUIPC3 for such a requirement, but FSUIPC4 and WideClient are still open to small changes when needed. Just give me a good reason, please.

Note that even with a more accurate system, other factors could still contrive to make the interval longer than requested.

Regards

Pete

Link to comment
Share on other sites

Thanks for the quick reply.

I'm actually using FSX but on a rather powerful rig (i7@5ghz).

I'm using the sleep function in a custom lib that plays sounds to a Teamspeak channel.

The “play-function” returns the sound files duration witch I used in a ipc.sleep. I noticed the problem when new sounds began playing before the previous sound had finished.

I guess I can solve this by multiply the duration by 1.1- but that will maybe get me new possible problems?

Best regards

Bleedin

Link to comment
Share on other sites

I guess I can solve this by multiply the duration by 1.1- but that will maybe get me new possible problems?

I wouldn't have thought so, but I'll release an updated FSUIPC4 which is more accurate with Sleeps with larger values. Give me a few minutes ...

... BTW, how did you get your i7 stable at 5GHz? I'm running at 4.8GHz. It will go to 4.9 but is a little unstable then. I guess i need better tweaking somewhere. It was a specially selected processor, higher price.

Pete

Link to comment
Share on other sites

I wouldn't have thought so, but I'll release an updated FSUIPC4 which is more accurate with Sleeps with larger values. Give me a few minutes ...

Get this and let me know, please, before I release it. FSUIPC4869.zip

... BTW, how did you get your i7 stable at 5GHz? I'm running at 4.8GHz. It will go to 4.9 but is a little unstable then. I guess i need better tweaking somewhere. It was a specially selected processor, higher price.

Pete

Link to comment
Share on other sites

I run a Intel Core i7 2700K @ 5GHz with a Corsair H80 cooler on a Asus Sabertooth Z77.

No stability issues whatsoever. I'm not sure if it's good hardware or just plain luck.

Luck with the processor I guess. Mine is not quite as up to date as yours. H100 cooler, but Asus Maximus Extreme P67. Maybe it's the Z77 chipset. Ah well. I doubt I'd really notice the difference between 4.8 and 5.0 -- it was just a magic number I originally targetted. ;-)

Pete

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.