From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <201102181753.30125.dexen.devries@gmail.com> References: <201102181445.41877.dexen.devries@gmail.com> <201102181753.30125.dexen.devries@gmail.com> Date: Fri, 18 Feb 2011 11:59:42 -0500 Message-ID: From: "Devon H. O'Dell" To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [9fans] Modern development language for Plan 9, WAS: Re: RESOLVED: recoving important header file rudely Topicbox-Message-UUID: b0855054-ead6-11e9-9d60-3106f5b1d025 2011/2/18 dexen deVries : > On Friday, February 18, 2011 04:15:10 pm you wrote: >> Benchmark utilities to measure the overhead of syscalls. It's cheating >> to do for getpid, but for other things like gettimeofday, it's >> *extremely* nice. Linux's gettimeofday(2) beats the socks off of the >> rest of the time implementations. About the only faster thing is to >> get CPU speed and use rdtsc. Certainly no other OS allows you to get >> the timestamp faster with a syscall. > > Would you mind explaining what technique is used by Linux to speed up the > gettimeofday()? I'd guess it's not per-process caching... and if it's not, > then it involves two context-switches; not the fastest thing in my books. The high level overview is that it is stored in a shared page, mapped into each new process's memory space at start-up. The kernel is never entered; there are no context switches. The kernel has a timer that updates this page atomically. --dho