Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Feb 2002 17:40:35 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Julian Elischer <julian@elischer.org>
Cc:        Matthew Dillon <dillon@apollo.backplane.com>, Alfred Perlstein <bright@mu.org>, Poul-Henning Kamp <phk@critter.freebsd.dk>, arch@FreeBSD.ORG, jhb@FreeBSD.ORG, peter@wemm.org, jake@locore.ca
Subject:   Re: gettimeofday() and crhold()/crfree() (was Re: gettimeofday()and  copyout(). Is copyout() MPSAFE on non-i386 archs? )
Message-ID:  <3C6F0A13.258882FF@mindspring.com>
References:  <Pine.BSF.4.21.0202161647070.39539-200000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This whole cred thing on gettimeofday is silly.

I was able to ensure that the contents of a copy of the
timecounter context struct were rotated between two
buffers with an atomic pointer update, each time they
were updated.

I really don't understand the need for a very large
pool of these things, and I don't really understand
the need for locking, so long as the pointer change
is atomic, and the clock update is always handled b y
a single processor.

By taking this single page, two structure, area, and
setting up an additional mapping, read-only, with
the PG_G and PG_U bits set, the pointer can be
directly dereferenced from user space, providing an
accurate zero system call "gettimeofday" call (the
easy part is copying the kernel space code for the
structure content use to user space).

With the PG_U bit set on the page, the same pointer
can be used in both user and kernel space to access
the snapshot structure, so there's no decoherence
from the change from kernel space copy to user space
dereference.

Pretty simple, actually.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C6F0A13.258882FF>