From owner-freebsd-current Wed Mar 29 22:47: 7 2000 Delivered-To: freebsd-current@freebsd.org Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.40.131]) by hub.freebsd.org (Postfix) with ESMTP id E89A837BC55; Wed, 29 Mar 2000 22:47:00 -0800 (PST) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost.freebsd.dk [127.0.0.1]) by critter.freebsd.dk (8.9.3/8.9.3) with ESMTP id IAA02923; Thu, 30 Mar 2000 08:46:57 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: Mike Smith Cc: Alfred Perlstein , Matthew Dillon , freebsd-current@FreeBSD.ORG Subject: Re: Using packed structs to gain cheap SMP primatives In-reply-to: Your message of "Wed, 29 Mar 2000 22:31:17 -0800." <200003300631.WAA00497@mass.cdrom.com> Date: Thu, 30 Mar 2000 08:46:57 +0200 Message-ID: <2921.954398817@critter.freebsd.dk> From: Poul-Henning Kamp Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <200003300631.WAA00497@mass.cdrom.com>, Mike Smith writes: >> Yesterday I was looking at how Linux handles the gettimeofday stuff >> without locking thier sys_tz variable, well it seems they don't care >> or I'm missing something important. >> >> They just don't lock it, not that settimeofday will be called all that >> often but it leaves me wondering what we can do about this, effectively >> we can pack our tz (sys_tz in Linux) into a 32bit value which should >> afford us read/write atomicity on every platform I'm aware of. >> >> In fact this can be quite effective for certain types of data structures, >> even though our 'struct timezone' is two ints we can pack it into two >> uint16 and pack a private structure, then copy it to a stack and expand >> it into the user's address space. > >It would be cheaper just to lock the bloody thing, although you can't >pack all the significance of a timeval into 16 bits anyway (in a fashion >that's going to make many people happy). Or do the "stable-storage" thing with it, and just grab a copy of the pointer (which will be an atomic op). See timecounters for an example. -- Poul-Henning Kamp FreeBSD coreteam member phk@FreeBSD.ORG "Real hackers run -current on their laptop." FreeBSD -- It will take a long time before progress goes too far! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message