Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Incorrect time_t value from time() in signal handler
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Mikhail Teterin, post: 2480358"] I would think, that for a program (potentially) logging tons of lines per second (such as a busy web-proxy or server), it is more efficient to set the SIGALRM-handler to a function, that would update the static time_t variable once per second. That static variable could then be used by the logging function instead of calling time() for every line logged many times per second (unless, of course, the precision of the timestamp must be finer than a second). Now, assuming that sig_atomic_t is as wide (or wider) as time_t, this can be achieved by simply incrementing the variable once per second. However, unless working on a RealTime OS, the signal may not, actually, arrive at the exact time specified, and may, in fact, be delayed by many seconds. So time() will need to be called at least occasionally to readjust/catch up, if not every second -- as, I suspect, the original poster is doing. Syscalls are relatively expensive and software like web-proxies and web-servers are frequently benchmarked -- even a small gain can make a winner... How can this be done (semi-)portably? -mi [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Incorrect time_t value from time() in signal handler
Top