Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I don't have the exact answer, so I would not have jumped in before now. But this question has been hanging for enough hours that I would like to make the following observations.
First, your code is more easily modifiable if you use #define for defining certain constaints, for example in assignments to it_value.tv_nsec, it_interval.tv_sec, and it_interval.tv_nsec. Put these #defines near the beginning of your code, all in one place.
Second, once you've done that, you can more easily play with those values and run experiments of your own. Make the pause interval longer, for example, and modify the time yourself in a separate window while your program's running, to see what the effect is.
Third, to maximize readability, when you post code, please put it between CODE tags. This is most easily done as follows:
Click the Go Advanced icon at the bottom of your editing window.
Highlight the code itself in the new editing window.
Click the # icon at the top of your editing window.
Fourth, when you post code, if at all possible, isolate the code as a separate, free-standing program that people can compile (which means you've already included the necessary #include statements) and run. This lets them run experiments. Heck, maybe you can run those experiments yourself and save waiting all this time for an answer.
Hey thanks for that, future posts I will be sure to use the "code" feature.
Unfortunately, the code is pretty deeply embedded into a complete package which I am trying to maintain, the previous software engineer has been gone for a long time.
It all comes down to how the timer runs.. if the OS assumes a "counter" e.g, for 1 sec interval.. count to ten.. then if I change the time, the counter value keeps running and will spit my out at a different time.. (wrong by however much I altered the clock).
Alternatively, if the OS uses a "compare", ie for one sec interval at the 0.5s, if (nsec == 500 000 000, and sec = old sec + 1) trigger timer; this will accept the altered clock and be cool..
Maybe I need to read more documentation about the implementation of the timers¿¿¿???
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.