Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Clemens Ladisch Newsgroups: comp.os.linux.misc,comp.os.linux.hardware Subject: Re: Realtime clock accessible without context-switch? Date: Thu, 22 May 2014 20:36:04 +0200 Lines: 25 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net Mpp6ZLYGjo9E4KL51qAA+gZoZfvrNUxISjMfoAupm2T68RKNXU Cancel-Lock: sha1:3cNRpyKsqcm+NgqPSG2+kbl7q/Q= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Xref: csiph.com comp.os.linux.misc:11117 comp.os.linux.hardware:2397 Charles T. Smith wrote: > On Wed, 21 May 2014 23:35:22 +0100, Richard Kettlewell wrote: >> Clemens Ladisch writes: >>> An I/O access (about one microsecond) is much slower than the SYSCALL >>> instruction; and with the RTC, you'd need to read several registers. >> >> As it happens, fetching the current time doesn’t involve a syscall >> anyway (on amd64). Yeah; the kernel reads the realtime clock once when booting, and then tries to avoid touching it ever again by using another clock to track the current time. > And I'm reasonably sure that doing a task switch on linux has much more > involved in it than just the trap instruction itself. On AMD64, a system call does not involve a trap; it's just a jump to a predefined address that also switches the privilege level so that the kernel code is allowed to access all memory pages. A task switch has to save and restore all registers, and to switch page tables if the new task is in another process. Regards, Clemens