LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-06-2009, 08:43 AM   #1
cagri_balkesen
LQ Newbie
 
Registered: Feb 2009
Posts: 1

Rep: Reputation: 0
gettimeofday() - execution time and underlying implementation details


Dear all,

I have a question regarding gettimeofday() function on Linux. I wrote a simple benchmark to understand the execution time of gettimeofday() function. I used ACE High Resolution Timer library to measure the timings (which in fact uses rdtsc instruction). My measurements claim that it takes 1.7 usecs as median and 1.8 usecs as mean value. Which is quite big for the scenario that I'm planning to use gettimeofday(). What I want to learn is whether it is doing a system call or reading the value out of a shared mapping in my system? Also I wonder what timer hardware does linux use for gettimeofday. Also I'm getting kernel timestamped datagrams from network layer (using SO_TIMESTAMP option on the socket), so another question is, does it also take around the same time when kernel receives the packets from the network and timestamps them with gettimeofday()?

Here is information about my system: Linux Red Hat 2.6.18-128.el5 #1 SMP x86_64 GNU/Linux

I'd be grateful to anyone who might share knowledge on this issue.

Thanks,

Cagri
 
Old 02-08-2009, 01:27 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
strace shows that gettimeofday is a system call. You also have glibc working on timezone conversion there. If you want to call it often, you probably do not want to use the full functionality. Just call it once and use your rdtsc wrapper of choice for updating timer information...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Execution Time Sanjib_Sur Linux - Newbie 3 12-02-2008 01:20 PM
Ext3 implementation details gobi_dgm Linux - General 2 04-08-2008 07:24 AM
Implementation details of sftp. vineeth_thampi Linux - Security 1 11-25-2005 07:41 PM
how to [time] the execution hq4ever Linux - General 8 07-03-2004 04:57 AM
time, gettimeofday h/w Programming 13 12-08-2003 05:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration