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

  • SEARCH
  • Home
  • 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
I want to execute a function on all the objects within a List of
In PHP, I want to execute a function when a hyperlink is clicked. The
I wish to execute a javascript function after asp.net postback with out using ajax.
I'm using jQuery to listen to DOMSubtreeModified event, and then execute a function. What
What's the jquery way to make hover function execute once and then stop? .one()
I want to call a function once per frame between keyframe 1 and keyframe
I need to execute a piece of code ONCE every first day of the
How can I execute a function on an element as soon as it comes
I have an application in VC++ which needs to execute a function provided to

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.