Thread: Suggestions for a quick way to create/check a timestamp for a threshold.

  1. #1
    Registered User lantzvillian's Avatar
    Join Date
    Sep 2010
    Posts
    44

    Suggestions for a quick way to create/check a timestamp for a threshold.

    Hi guys,

    I have looked around and there are numerous timestamp implementations, but I'm looking for your advice on how to create and check a timestamp in the quickest method with minimal overhead (obviously this is subjective).

    To give you an idea:

    * This is for embedded hardware with minimal resources
    * This doesn't have to be very accurate - its just a way to rate limit syslog messages.

    Ideas folks?

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    If your system doesn't have sys/time.h or an equivalent header, you could potentially spawn off a thread with a shared counter that infinitely slept for one second and then incremented the timer..

  3. #3
    Registered User lantzvillian's Avatar
    Join Date
    Sep 2010
    Posts
    44
    Could spawning a thread lead to concurrency issues though especially since this will be cross compiled? multi-threading isn't too common on limited hardware.

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    How accurate does it have to be? Using the threading method would probably give you granularity up to a second.

    But if you can't thread/don't have enough resources to thread, have you tried interfacing with the CPU cycles register? On some architectures, the computer's internal clock can be read, and you then could use that to calculate/keep track of time.

  5. #5
    Registered User lantzvillian's Avatar
    Join Date
    Sep 2010
    Posts
    44
    It doesn't have to be scientifically accurate - I think I can check the CPU's clock for ticks.

    Essentially.. it is possible I will be seeing 1000+ packets per second and I don't want to pound either my system or the logging server.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 12-27-2011, 11:22 AM
  2. Need a quick check
    By Aliaks in forum C++ Programming
    Replies: 7
    Last Post: 06-05-2009, 04:57 AM
  3. Replies: 3
    Last Post: 05-09-2009, 11:06 AM
  4. Quick input check question
    By Jozrael in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2009, 07:23 AM
  5. Suggestions for my Check Book program
    By Nor in forum C++ Programming
    Replies: 2
    Last Post: 11-17-2008, 06:44 PM