Thread: Async timer in C

  1. #1
    Registered User
    Join Date
    Aug 2019
    Posts
    9

    Async timer in C

    Hello,

    How can i call a function so i can call the code, while the code is running.

    what i waht is:
    run some code, while the code is running i will run a code async (apart the other code)

    Thanks for helping me

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Depends on what you're running asynchronously and for how long.

    You can get very limited functionality through alarm() and a signal handler.
    alarm(2) - Linux manual page
    sigaction(2) - Linux manual page

    But bear in mind, what you can call inside a signal handler is very limited. You couldn't call for example printf.
    signal-safety(7) - Linux manual page


    If it's all I/O that you want to be asynchronous, then perhaps this.
    aio(7) - Linux manual page


    For full blown do whatever you need async, then go for threads.
    pthreads(7) - Linux manual page
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Quote Originally Posted by 007fred50 View Post
    Hello,

    How can i call a function so i can call the code, while the code is running.

    what i waht is:
    run some code, while the code is running i will run a code async (apart the other code)

    Thanks for helping me
    Where will the code be running?

    i.e, Linux, Windows, AVR, PIC, ...

  4. #4
    Registered User
    Join Date
    Aug 2019
    Posts
    9
    I'm working on ubuntu (linux) and Mac OS

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. async programming question
    By sothy in forum C Programming
    Replies: 4
    Last Post: 02-04-2018, 02:49 AM
  2. Understanding Async Code
    By EverydayDiesel in forum C++ Programming
    Replies: 9
    Last Post: 04-01-2016, 08:19 AM
  3. Threads vs async events
    By zacs7 in forum Tech Board
    Replies: 4
    Last Post: 02-10-2010, 10:29 PM
  4. async socket issues
    By ZerOrDie in forum Windows Programming
    Replies: 2
    Last Post: 03-16-2003, 06:10 PM
  5. Async Socket Examples?
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 01-04-2002, 06:08 PM

Tags for this Thread