How does one make something real time? [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
This might be a really stupid question, but I can't find any info on this, and I can't find out what to search for.
How do you make something real time? For example, say we have a game, how does it run continuously without us calling a tick() method at different parts of the program?

If you are developing the program to run at a time in particular the best way I know of is to develop it to run at a particular loop rate using timed delays.
IE:
while(forever) {
do something
test how long it took
take up the remainder amount of time for the loop to run at a rate (ie 100Hz)
}
If you are desperate for real time applications you can develop and use QNX:
http://www.qnx.com/
But this certainly wouldn't be a good environment for programming games.

Related

Online compiler/server to run big programs [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I've written a program to generate a fractal, but my computer would take a week to compute it. Is there any online or otherwise, solution where I can run my code and have it compute quickly?
No, not to be rude and don't take this wrong. Nobody is going to let people use there full computer's resources over the web to let you run code, it will always be slower online. For free.
However VPS and Cloud-Computing options are available. They will be expensive for a really fast computer.

Sequential and running in one thread time difference c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Here is my source code for testing multithread performance in C++. Please tell me why is time about 5x smaller for ONE thread running(WaitForMultipleObject()) then first sequential performance. I expect almost same result for sequential performance and running with only one thread. Thanks
http://pastebin.com/EeJ5qW03
OS will decide when will your thread start running and it will also decide if there's a need for dispatching, perhaps. Add to that, it also has to create a separate stack for your thread, perhaps.
Read about the overhead on thread creation. All in all, the overhead is system specific.

Anyone have the algorithm for determine if a hand of Mahjong game wins or not? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am reading some introduction of an ancient Chinese game called Mahjong (a bit like poker but far more complicated). I have been spending couple days in writing a program to determine if a given hand is a win hand or not. Do anyone have any idea or know where can I find the free code for that? I only need the part to determine win/lose, I am not looking for the entire project. Thanks.
There is this cool Python library that can be used for scoring of a Mahjong hand given a situation. I know you are working in C++, but since python is highly readable, even to non-python coders, maybe you'll be able to copy/paste and edit the relevant part so you'll be able to use them.
Hope that helps you in some way.

C++ multiple process shared memory implementation [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Here's what I am trying to accomplish.
I want program1 to create a shared memory segment where I store various arrays.
Then, I want program2 to read in the arrays and modify them.
This sounds pretty simple, but for some reason, I cannot find a single example online that shows how this is done. Every example I have found uses a single program (e.g the initialize, read and write are both done by program1).
If somebody can provide an example here, I'm sure this would be hugely beneficial for pretty much everybody that wants to use IPC in C++.
Boost.Interprocess has a guide for the impatient.

get instant energy consumption [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I am looking to get instant energy consumption, in shell or C++
any ideas ?
Thanks
Your question could do with a bit more detail, but if I understand you correctly a program named Joulemeter does this the following way:
Joulemeter estimates the energy usage
of a VM, computer, or software by
measuring the hardware resources (CPU,
disk, memory, screen etc) being used
and converting the resource usage to
actual power usage based on
automatically learned realistic power
models.
That is one way to go. If you're just doing this for your own project, I guess you could throw together some hardware that measured from the wall socket and gave you the data that way. Maybe something like that exists already.
Well, if you have a Laptop you could use the answer presented for this similar question:
/usr/sbin/system_profiler SPPowerDataType | grep Wattage