LWN.net Logo

gettimeofday() -- user-space vs. system call

gettimeofday() -- user-space vs. system call

Posted Feb 7, 2007 16:53 UTC (Wed) by nix (subscriber, #2304)
In reply to: gettimeofday() -- user-space vs. system call by AnswerGuy
Parent article: Comparing Linux and Minix

You don't need any libc support for this (other than the existing vsyscall support). The code on the vsyscall page which normally runs SYSENTER could spot that the syscall being invoked is gettimeofday() and copy out the appropriate value from elsewhere in the vsyscall page without ever transitioning to kernel mode. (A patch of this nature was discussed a few years ago, but I'm not sure if any code resulted.)


(Log in to post comments)

gettimeofday() -- user-space vs. system call

Posted Aug 23, 2010 13:09 UTC (Mon) by Blaisorblade (guest, #25465) [Link]

The mechanism you describe is only valid for i386.
That mechanism is used on x86_64, for one - see arch/x86/kernel/vsyscall_64.c:vgettimeofday and/or arch/x86/vdso/vclock_gettime.c (two different reimplementations of the same concept).

However, the existing implementation for x86_64 requires libc support, and no implementation of this for x86_32 exists. Dunno why.
The only difference I seem to see is that on i386 there is no support for int 0x80 calls, so probably libc uses syscall/sysenter directly.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds