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 6215795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:07:12+00:00 2026-05-24T07:07:12+00:00

When I set a short timeout with setitimer and then query the set value

  • 0

When I set a short timeout with setitimer and then query the set value (with getitimer or another setitimer) on a Linux 2.6.26 system (Debian 5.0.5), I get back a value higher than I set:

#include <sys/time.h>
#include <iostream>

int main() {
  struct itimerval wanted, got;

  wanted.it_value.tv_sec     = 0;
  wanted.it_value.tv_usec    = 7000;
  wanted.it_interval.tv_sec  = 0;
  wanted.it_interval.tv_usec = 0;

  setitimer(ITIMER_VIRTUAL, &wanted, NULL);
  getitimer(ITIMER_VIRTUAL, &got);

  std::cerr << "we said: " << wanted.it_value.tv_usec << "\n"
            << "linux set: " << got.it_value.tv_usec << std::endl;

  return 0;
}

returns:

we said: 7000
linux set: 12000

This is problematic, since we use the times reported as remaining after some computations, and they are way too large, too.

Is this a known problem? (googling did not work.) Does anyone have a good workaround?

  • 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-24T07:07:13+00:00Added an answer on May 24, 2026 at 7:07 am

    In the POSIX documentation of the setitimer function there is a note

    Implementations may place limitations on the granularity of timer values. For each interval timer, if the requested timer value requires a finer granularity than the implementation supports, the actual timer value shall be rounded up to the next supported value

    The granularity in your system seems to be higher than 1000 usec (seems to be 6000 usec) and the timer value is rounded up. The timer granularity is the problem if you need such precision.

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

Sidebar

Related Questions

I would like to set a short connection timeout (only some seconds) when using
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
SHORT VERSION OF QUESTION: So basically my question is: How can I set the
I'm initializing an unsigned short int with a = 0xff (all bits are set).
I have a SVNSERVE server set up to host multiple repositories. Short question here
Currently I use a HashMap<Class, Set<Entry>> , which may contain several millions of short-lived
I want to sort results set first based on one column and then based
I'm POST'ing a small image, so i'd like the timeout interval to be short.
What is the best way of replacing a set of short tags in a
In short, is there a way to set the outerWidth? $.outerWidth(true, newValue) Update: I

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.