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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:23:25+00:00 2026-06-11T16:23:25+00:00

I’m looking for an open source timer library written in C. The library should

  • 0

I’m looking for an open source timer library written in C. The library should have Timer callback functions, etc.

On searching I see POSIX timers or setitimer(), which use a signal based approach that may lead to problems in multithreaded code.

Say if I use POSIX Timers inside threaded code, the signals won’t be reaching to the correct place. If I use several timers in a process then each one should use different signals. Are there any other alternatives?

  • 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-06-11T16:23:27+00:00Added an answer on June 11, 2026 at 4:23 pm

    Since you are running Linux, I would recommend using the built in POSIX timer API’s.

    int timer_create(clockid_t clockid, struct sigevent *sevp, timer_t *timerid);
    

    Here is a link to some documentation showing how to use POSIX timers which provide support for callback functions.

    Regarding multiple timers in a process, the documentation says this:

       A program may create multiple interval timers using timer_create().
    
       Timers are not inherited by the child of a fork(2), and are disarmed and
       deleted during an execve(2).
    
       The kernel preallocates a "queued real-time signal" for each timer created
       using timer_create().  Consequently, the number of timers is limited by the
       RLIMIT_SIGPENDING resource limit (see setrlimit(2)).
    

    Note that POSIX timers can be used in a threaded application by setting up notification using SIGEV_THREAD_ID as shown below:

    The sevp.sigev_notify field can have the following values:
    
           SIGEV_NONE
                  Don't asynchronously notify when the timer expires.  Progress of the
                  timer can be monitored using timer_gettime(2).
    
           SIGEV_SIGNAL
                  Upon timer expiration, generate the signal sigev_signo for the process.
                  See sigevent(7) for general details.  The si_code field of the
                  siginfo_t structure will be set to SI_TIMER.  At any point in time, at
                  most one signal is queued to the process for a given timer; see
                  timer_getoverrun(2) for more details.
    
           SIGEV_THREAD
                  Upon timer expiration, invoke sigev_notify_function as if it were the
                  start function of a new thread.  See sigevent(7) for details.
    
           SIGEV_THREAD_ID (Linux-specific)
                  As for SIGEV_SIGNAL, but the signal is targeted at the thread whose ID
                  is given in sigev_notify_thread_id, which must be a thread in the same
                  process as the caller.  The sigev_notify_thread_id field specifies a
                  kernel thread ID, that is, the value returned by clone(2) or gettid(2).
                  This flag is only intended for use by threading libraries.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.