How do I schedule a userspace application to run at regular intervals
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
I am writing a userspace application to send out a packet on uClinux on Nios2, it needs to be run at regular intervals (from about 1 to 64 times a second - to be set by user) but the timing does not need to be accurate (otherwise I would use a hardware counter to generate interrupts).
Can I some how create a software interrupt/timer overflow or something along those lines to start my application every second? Or some way I can use a shell script to start it?
I have read up about Kernel Timers but I would prefer to not have to write another driver.
I could just wrap the program in a while loop with a delay but this seems very crude. This is an embedded system so there is a need to conserve resources.
No matter how you do it, starting a program every second will take quite a lot of resources. So I think it's better to have the program start once and then just sleep/usleep/nanosleep in the while loop. Why do you think it's "very crude"?
It is not crude to delay a process. If you sleep a process it is simply not run by the kernel until the moment the sleep timer expires, and it doesn't take up any resources.
For repeating jobs with a period less than 2 minutes, it is recommended to start the process once and have a sleep to schedule when parts of the program must be run.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.