Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261193AbVCZRmY (ORCPT ); Sat, 26 Mar 2005 12:42:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261197AbVCZRmY (ORCPT ); Sat, 26 Mar 2005 12:42:24 -0500 Received: from linux01.gwdg.de ([134.76.13.21]:18570 "EHLO linux01.gwdg.de") by vger.kernel.org with ESMTP id S261193AbVCZRmT (ORCPT ); Sat, 26 Mar 2005 12:42:19 -0500 Date: Sat, 26 Mar 2005 18:42:15 +0100 (MET) From: Jan Engelhardt To: Kyle Moffett cc: Linux Kernel Mailing List Subject: Re: gettimeofday call In-Reply-To: <4de75d4e913f9c7fc93bde5ee6ec57b0@mac.com> Message-ID: References: <4de75d4e913f9c7fc93bde5ee6ec57b0@mac.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1065 Lines: 44 >> I suppose that calling gettimeofday() repeatedly (to add a timestamp to >> some data) within the kernel is cheaper than doing it in userspace, is it? > > Well, the following daemon works on most archs that support mmap at only [...] Ah, it does not need to be that complex. Just comparing two approaches: --1-- /* KERNEL: Calling read() on a character device */ static int u_read(...) { ... gettimeofday(tv); enqueue_in_buffer(tv); ... } +nothing needed in userspace --2-- /* KERNEL: No gettimeofday */ Userspace: while(read(fd, buf, sizeof(buf)) { gettimeofday(&buf.tv); ... } (In either case, at some point, userspace has a timestamp.) I think that -1- is faster it does not require an additional syscall from userspace to sys_gettimeofday(). Jan Engelhardt -- No TOFU for me, please. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/