Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620842
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:36:54+00:00 2026-05-22T02:36:54+00:00

How do I execute a function once every 1000 milliseconds using alarm() or sleep?

  • 0

How do I execute a function once every 1000 milliseconds using alarm() or sleep? I want the program to do something else if the function does not execute or complete in 1000 milliseconds.

EDIT: added Pseudocode

while(true) {
alarm(1000);
execute function;
sleep(1000);
alarm(0);
}

Now if alarm(1000) signals SIGALRM is this where I could call the other function?
I’m new to this sort of stuff so not even sure if I am using it right.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:36:55+00:00Added an answer on May 22, 2026 at 2:36 am

    How crisp is the requirement, ie, how much jitter can you tolerate?

    What version of UNIX?

    Basically, if this is a hard deadline — it sounds like one — you’re going to need to do some special stuff, because basic UNIX isn’t really a hard-real-time system.

    Let’s assume for the moment that you mean Linux. You’ll want to

    • use nice(2) to raise the process priority
    • use a fine-grained timer, as with ualarm(3)

    That will probably do. If you need finer grained, or more predictable, timing, then you probably need to write a kernel extension to it can be driven with a kernel timer. (Solaris has some improved support for hard-real-time, but it’s still not really a hard real-time system.)

    Life will get considerably easier if you can use a real-time Linux or UNIX. Here’s a list of some options. Here’s an article you might find usefui.

    Update

    You should also look at nanosleep(2) or setitimer(2). Notice that all of these say the interval is at least the one in the argument. If you have a hard deadline, you need to wait for somewhat less than the actual interval and then figure out what to do with any change on your thousand millisecs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to repeatedly execute a function in Python every 60 seconds forever (just
Without using a WebBrowser control, how could I execute a JavaScript function, that is
Is there a way to execute a query(containing built in DB function) using PreparedStatement?
PHP (among others) will execute the deepest function first, working its way out. For
using register_shutdown_function I can register code to execute at the end of a PHP
How can you measure the amount of time a function will take to execute?
When using the php include function the include is succesfully executed, but it is
tldr> Once a customer has been selected, how can all other controllers execute their
Is there a way to execute SQL custom functions with Enterpise Library? I've tried
When you execute a SQL query, you have to clean your strings or users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.