Thread: synchronous function

  1. #1
    Registered User
    Join Date
    Sep 2007

    synchronous function

    What is the difference between synchronous and asynchronous functions?
    How could i make an asynchronous function synchronous ?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    This probably depends on "who you ask".

    Generally, something is Asynchronous when it happens without influence of something else.

    In the case of functions, they are almost always Synchronous in the sense that a function is called by some part of your code, and you get back to the calling function when the callee finishes.

    You can use asynchronous calls in some OS's to read or write data to/from files - This is called "Asynchronous IO". This works along the principles of:
    1. You send a packet off to the filesystem to be written.
    2. The write function returns almost immediately.
    3. (Optionally) Some other code runs in the application.
    4. Application waits on some synchronization object (e.g. a semaphore) for the write to complete.

    There are plenty of other cases of asynchronous behaviour in computer systems - I'd need more specifics on what you are referring to, if you want more details.

    To make an asynchronous function synchronous, you'd have to implement the "wait" inside the function, rather than make it happen later on in another place.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM