The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Clock in Unix using awk alex_omul UNIX for Dummies Questions & Answers 4 04-02-2008 03:07 AM
clock change markab2 UNIX for Advanced & Expert Users 0 10-31-2007 04:58 AM
how to differentiate system call from library call muru UNIX for Advanced & Expert Users 2 07-19-2007 08:20 PM
clock() function kastrup_carioca High Level Programming 5 06-13-2005 07:05 AM
Why don't my clock show am or pm? CTroxtell21 Linux 2 11-13-2004 06:35 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-21-2007
Registered User
 

Join Date: Dec 2006
Posts: 19
clock() call returning zero always

Hi,

Is there a chance that the clock() call returns 0 eternally???
Using BSD. My RTOS application freezes inconsistently only on particular hosts. When debugging it, I came to see that the RTOS timer does not tick at times. The underlying system call is clock() & it always returns zero when the problem under question occurs. Consequently the RTOS timer does not tick or go further in time.

Is it possible that some patches are missing on the hosts where my RTOS applications freeze?

If so, how do I find out which patches are missing based on the given info?

I guess clock() call does wrap after certain time (36 minutes approx). But I do not think it will return 0 for a long time...
Reply With Quote
Forum Sponsor
  #2  
Old 05-21-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,618
clock() is subroutine, not a system call on FreeBSD. And the man page says:
Quote:
Do not use clock(3) in new programs under FreeBSD. It is feeble compared with getrusage(2). It is provided for ANSI conformance. It is implemented by calling getrusage(2) and throwing away information and resolution.
So while it is possible that clock() is misbehaving, I have to think that you aren't looking at the man pages very closely. You could be invoking clock() wrong or be expecting it to report elasped time rather than cpu utilization. And yes, it would not surprise me too much if several consecutive calls to clock() returned zero provided that the program was using very little cpu. I would follow the man page's advice and switch to getrusage().
Reply With Quote
  #3  
Old 05-21-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,275
If you are strictly interested in cpu time in user mode and/or kernel mode, consider times().
Reply With Quote
  #4  
Old 05-22-2007
Registered User
 

Join Date: Dec 2006
Posts: 19
I actually use the RTOS timer already written by a third party. clock() is used by them & it has been in use for five years now, no problems for long. Only recently the RTOS applications started freezing inconsistently when run on certain Faster Hosts with SunFire V215, 2 CPU.

The chances that I can modify the timer functionality immediately is low.
I want to check if it's clock that is faulty or something else?
And if it clock() that is faulty, do you have any hint of suitable patch that can correct it?
Reply With Quote
  #5  
Old 05-22-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,618
clock() is probably working correctly. Your third party assumed that some code would consume enough cpu time to register as non-zero when measured by clock(). You now have a CPU where this is not true. Induce the third party to fix the app or get some slower CPU's. Be warned though, the day will come when there are no CPU's available that are slow enough to run your app.

Wow, though! You are running BSD on a SunFire V215! That's pretty awesome. What version of BSD?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0