Thread: how can I achive when, do?

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485

    how can I achive: when, do?

    What different ways are available to achive an action, when a specific event has occured besides a callback or making a loop that does nothing but wait for a condition to become true?

    I have read up a bit on signals in unix, would it be possibel to make a function pause until it recieves a signal from another function?

    I have used the "waiting in a loop" for now but it wastes a lot of cpu resources.
    Last edited by Subsonics; 03-20-2009 at 07:31 AM.

  2. #2
    apprentiCe
    Join Date
    Oct 2008
    Location
    Hyderabad,India
    Posts
    136
    i dont quite understand what your requirement is...but if its multiprocessing feature you are looking for then...

    http://www.opengroup.org/onlinepubs/...ions/fork.html
    http://www.opengroup.org/onlinepubs/...six_spawn.html

    if you want to make a function wait for another function then...

    http://www.opengroup.org/onlinepubs/...ions/wait.html
    http://www.opengroup.org/onlinepubs/...igsuspend.html

    for threads
    http://www.opengroup.org/onlinepubs/...ons/pause.html
    Last edited by creeping death; 03-20-2009 at 07:53 AM.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Thank you, as far as I can tell pause could work it seems. What I have is a loop that sends packets from a packet array to a network, but the condition is that a packet canīt be sent until an o.k flag has been recieved.

    The input is handled by a callback in another thread that polls the input. If I can get my loop to pause after each packet until it recieves a signal that the packet arrived successfully that would be great.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can we achive this?
    By ssharish2005 in forum C Programming
    Replies: 5
    Last Post: 09-19-2007, 11:46 AM
  2. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM