Thread: Trouble when try to implement a timer thread using C++ on linuxquestion

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    3
    Thanks for your kindly reply.

    According to your experience and method, it is not widely to use signal handler to implement, more better way is to use function usleep, sleep 250ms every time and then to update.

    So in the opinon of those language designer, it won't be good idea to write so many functions in the signal handler, am I right?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I think that using "signal" handler is a bad idea in this case, since there is a much better alternative. Like you say, usleep() will do a good job.

    --
    Mats
    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.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    3
    Quote Originally Posted by matsp View Post
    I think that using "signal" handler is a bad idea in this case, since there is a much better alternative. Like you say, usleep() will do a good job.

    --
    Mats
    Thanks very much for your reply.

    At first I have the idea to use SIGALRM since I find signal emit will be real time, but sleep will cause CPU ideal and waste resource, and at the same time sleep or usleep is also impemented by sending alarm signal periodly. When meeting difficulities, then I find signal method on this occasion isn't a good idea.
    Last edited by steven_yu; 12-20-2007 at 08:11 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a thread sleep or std::recv timeout?
    By BrianK in forum Linux Programming
    Replies: 3
    Last Post: 02-26-2003, 10:27 PM
  2. Multithreading
    By Cela in forum Windows Programming
    Replies: 13
    Last Post: 01-15-2003, 03:02 PM
  3. Your Best thread and your most stupid thread ??
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 01-03-2003, 07:41 PM
  4. MFC Controls and Thread Safety :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 12-06-2002, 11:36 AM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 02:53 PM