From owner-freebsd-current Thu Feb 7 21: 0:32 2002 Delivered-To: freebsd-current@freebsd.org Received: from rwcrmhc53.attbi.com (rwcrmhc53.attbi.com [204.127.198.39]) by hub.freebsd.org (Postfix) with ESMTP id E24D037B416; Thu, 7 Feb 2002 21:00:29 -0800 (PST) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc53.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020208050027.VWVB2951.rwcrmhc53.attbi.com@InterJet.elischer.org>; Fri, 8 Feb 2002 05:00:27 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id UAA99697; Thu, 7 Feb 2002 20:43:37 -0800 (PST) Date: Thu, 7 Feb 2002 20:43:36 -0800 (PST) From: Julian Elischer To: John Baldwin Cc: current@freebsd.org Subject: RE: ucred for threads In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 7 Feb 2002, John Baldwin wrote: > > > This code is not safe on SMP non-i386 machines (i.e. ia64, sparc64, alpha, and > possibly p3 and later i386's) because the p_ucred value you read could easily > be a stale value, thus rendering the test invalid. You need the lock for the > compare. Conceptually minimizing the crfree's isn't bad I guess. However, the > td_ucred pointer should nto be read if the thread is not in the kernel, and > having it set to NULL when we leave the kernel provides a conveninet way of > ensuring this doesn't happen since we will panic if we do. if the ucred is stale or not is completely unimportant. if you wish to ensure that all your threads get the new ID that you are setting then you need to synchronise them at the program level to ensure teh order in which they enter the kernel on their next system calls. There is no point is sychronising with locks because the threads in question may have run in any order anyhow. > > -- > > John Baldwin <>< http://www.FreeBSD.org/~jhb/ > "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message