Jump to content
The simFlight Network Forums

Recommended Posts

Posted

f*ck, I just red that Pete is away for 8 days... anyone else that can help me?

Hi Pete,

I'm programming something that keeps checking new fs data

while(!done){

FSUIPC_READ

FSUIPC_PROCESS

doSomethingWithData();

}

I once heard that this wasnt a good solution. that fsuipc needs more time before looping to the next fsuipc_process command.

Is this true ? should i wait 50ms before doing a loop again ? if this is the case, i'm going to look into threads i guess.

Thanks,

Wim Van Ertvelde

Posted

Why don't you use a timer? I don't know what you are doing with the data but generally if it an external program there is no need for such intensive query. Even in T/D analisys I use timers to light up the requests.

José

Posted

I once heard that this wasnt a good solution. that fsuipc needs more time before looping to the next fsuipc_process command.

Is this true ? should i wait 50ms before doing a loop again ?

The problem is two-fold:

1) Depending on what you do in "doSomethingwithData", your program is not relinquishing the processor and this will affect performance. Certainly, the call to FSUIPC_Process will cause a process switch, but doing this possibly very fast is actually only wasting much processor time switching unnecessarily.

2) The loading on FSUIPC, processing the end-to-end requests, is a loading on FS itself, which isn't a good thing. Since the most if not all of the data you are using cannot possibly change faster than the FS frame rate, most of those calls be will just an overhead and doing nothing useful.

The solution depends on what else the program is doing. If it is actually doing NOTHING except when it gets new data, and you don't mind it being rather unresponsive to user interventions, then simply try inserting a "Sleep" in the loop, say for 15 or 20 or more milliseconds -- experiment and use the biggest value which works well.

Alternatively, trigger this section of code on a windows timer call -- either by WM_TIMER messages or using the TimerProc facility in SetTimer.

Using the loop in a separate thread with a Sleep would also work, but is probably an unnecessary complication. Certainly do not have it in a thread with no Sleep, that could be worse (especially, as I found out recently, on Pentium 4 HyperThreading processors).

Regards,

Pete

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.