Jump to content
The simFlight Network Forums

What is the better way to program a read (or a write)


Recommended Posts

Good day all,

a fsuipc_read (or a write) seems to be performed very fast, but the fsuipc_process uses much more CPU.

So the question is: is it more efficient to make a lot of read and then only one fsuipc_process or is it better to issue a fsuipc_process after each fsuipc_read (or couple of read...) ?

Thanks by advance,

Robert

Link to comment
Share on other sites

a fsuipc_read (or a write) seems to be performed very fast, but the fsuipc_process uses much more CPU.

That's because the read and write calls merely add the request to a queue in your memory. They never leave your program. Only the Process call does anything -- that takes a while because it has to get windows to switch to the FS process, pass the data built up to FSUIPC, wait for the reply, then switch back.

So the question is: is it more efficient to make a lot of read and then only one fsuipc_process or is it better to issue a fsuipc_process after each fsuipc_read (or couple of read...) ?

NEVER do a Process after each read. The whole point of splitting the specification of what you want to read and write from the actual doing of it was for efficiency. You'll not only slow your program down, but you'll slow FS as well.

Ideally ALL of the things you want to read and write in each cycle of your program should be built up and sent in one Process call. The cycle is best if it is timed to be either the same as one FS frame, or a multiple of it (if you don't need things so urgently). If you get, say, 20 fps consistently from FS (set the limiter to something suitable) then sending a Process every 50 mSecs (or every 100, 150 etc) is best.

The only exception to saving everything up for one Process is for those cases where what you write needs to be decided upon from what you read. Then you may need to read something, do some calcs, and write something. Even then it would be more efficient to spread that over two of the above cycles, so "Read --- Write & Read --- Write & Read --- etc.

Oh, there is one other exception but it isn't likely to arise. That's when the total data size adds to more than the max size for one Process call -- around 30000 bytes. Don't get anywhere near that.

Pete

Link to comment
Share on other sites

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.